Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.NET String.Format() for VFP ?

Status
Not open for further replies.

awaresoft

Programmer
Feb 16, 2002
373
DE
Anyone heard of a VFP class that implements the functionality of the .NET String.Format() function?

String.Format() provides a convenient, powerful way to format info similar to VFP transform() or C printf() and sprintf() functions. Naturally the syntax is different. The formatting capabilities are also more flexible.

A brief overview of String.Format() is available at:

One could implement String.Format() functionality in VFP - just hoping to avoid re-inventing the wheel if this has already been done or if tried and abandoned for some reason.

Thanks!
Malcolm

PS: I am NOT interested in creating an interface to .NET CLR's String.Format() - my goal is .NET style formatting options in VFP without having to depend on the presence of .NET CLR.
 
Malcom,

No, I don't know of any existing class or function. But it would be extremely easy to write it in VFP, given all those nice string-handling functions like STRTRAN() and STRCONV().

Let us know if you decide to do so.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Mike,

Thanks for jumping in. I'm not sure I agree with the "extremely easy" comment - there are a ton of different formats and format picture clauses - with some picture clauses getting pretty complicated (not 1:1 char replacement). Plus the fact that .NET's String.Format() ties in to locale specific info.

In order to implement .NET's String.Format() in VFP, one one must first use the Windows API to read all (most?) National Language formatting properties (about a 100?) that VFP formatting engine must consult.

OR (???) perhaps the Windows API provides functions that will work with the .NET String.Format() formatting/picture codes - in other words, perhaps .NET's formatting/picture codes were derived from Win32 vs. being invented specifically for .NET? If this is indeed true, then perhaps one would just need to build a simple wrapper around a few Win32 formatting API calls?

What do you think?

Malcolm
 
Mike,

A follow-up ... I just checked Microsoft's Win32 "National Language Support Constants" and can verify that the .NET datetime formatting picture codes (d, dd, ddd, dddd, M, MM, MMM, MMMM, yy, yyyy, h, hh, H, HH, s, ss, t, tt) are the SAME as the Win32 datetime formatting picture codes.

There appear to be no Win32 equivalents to the .NET single char datetime format codes.

I'm searching for more info on Win32 numeric/currency formatting picture codes.

Malcolm
 
Malcom,

Well, maybe I was a bit optimistic when I said it would be extrememly easy. But I still think it wouldn't be that hard. All the date and time formatting options are available in VFP, and most of the format pictures have direct VFP equivalents.

That said, you are quite right to look for an existing class or method. Let us know if you come up with anything.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hi Mike,

Thanks for the encouragement. I've now spent a fair amount of time studying the scope of this type of project.

I'm not sure I agree with your comment that "most of the format pictures have direct VFP equivalents". If this were the case then I would simply use the VFP equivalents :)

There's lots of little nuances and the added complexity of supporting all the locale info that the String.Format method takes into consideration. VFP's locale specific formatting is OK but limited.

I am now of the opinion that almost none of the built-in VFP formatting functionality exposed through transform() would be applicable and that the ENTIRE formatting process would have to be implemented in code.

I'm not running away from this effort - just being realistic about its scope.

I think there's great benefits in having such a class available as it would provide a very concise and consistent way for developers to format content across platforms. In fact, with this capability in place, VFP and .NET projects could share the same resource strings.

... And the ability to have all this formatting power without the complexity and support issues of deploying the .NET CLR runtime ... priceless!

As you can see ... I'm trying to get myself psyched up for the effort and hoping that someone might have some tips on Win32 API calls and/or 3rd party DLLs (not ActiveX) and/or public domain VFP source code to help lighten the load.

Cheers!
Malcolm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top