Was playing in PHP this morning, then switched to a different project and was playing in Visual FoxPro, and as any multiple-language programmer will tell you, it's a bit annoying to shift between similiar languages, particularly because functions are generally just different enough to screw something up, or exist in one and not the other.
In my case this morning, I realized that VFP has no built-in function for calculating numbers in different bases - BASE_CONVERT() in PHP.
So I wrote a set of functions to do it.
Syntax is the same as the PHP version: BASE_CONVERT(NUMBER,BASEFROM,BASETO).
The functions have been tested in FoxPro Dos 2.6 and VFP 9.0 SP2, so should work in everything in between.
Source isn't pretty, but it IS functional, and fully commented.
Download the source PRG (ZIP) here.
"There are only 10 types of people in this world: Those that understand binary math and those that don't." - Unknown
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment