Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
OS()
, Sys(9), VERSION()
, VersionThese three functions and one property give you information about your software setup. OS()
provides DOS and Windows version information, while SYS(9), VERSION()
and the Application Object
’s Version property provide FoxPro version information.
cOpSys = OS( [ 1 | 2 ] )
Without the optional parameter, OS()
returns the underlying operating system and version. With a parameter of 1, you get the Windows version. However, these days, those two are generally the same thing. (In FoxPro for Windows 2.x, OS()
gave us a DOS version, while OS(1) gave us a Windows version.)
Passing 2 to OS()
tells you whether the operating system supports Double-Byte Character Sets
, a handy thing to know if you’re writing international applications. We can tell you that this option, released in VFP 6, works when you don’t have a double-byte system, but neither of us is in a position to test whether it works when you do have double-byte characters.
? OS() && Returns Windows 5.00 on Della's Win2K system
? OS(1) && Also returns Windows 5.00 on Della's system
? OS() && Returns Windows 4.00 on Ted's old Win95 system
? OS(2) && Returns "" on Della's system
cSerialNumber = SYS(9)
From the truly useless information department, we bring you SYS(9). It returns your Visual FoxPro serial number. Now there’s an item we use every day.
uVersionInfo = VERSION( nExpression )
cVersionNumber = appApplication.Version
Parameter |
Value |
Meaning |
nExpression |
Omitted |
Return product name and version. |
1 |
Return product name, version, date and serial number. |
|
2 |
Return edition information: |
|
0 – Runtime |
||
1 – Standard |
||
2 – Professional |
||
3 |
Return localization information. See Help for the list of languages. |
|
4 |
Return the version number portion only, but complete with all the major and minor and build number info. In VFP 7, the build number is in the fourth position, and in VFP 6, the build number is in the third position. Previous versions don't supply a build number. |
|
5 |
Return just the version number, as a number, not a string. The first digit is the major version number, and the other two are the minor revision number. |
VERSION()
and Version, on the other hand, we use. We use them interactively to determine which build of the product we have for bug reporting or to ensure that an application will run. We also use them in our applications because there are some things we want to do differently when running an EXE than when running on our development systems, and things we want to handle differently depending on the version of the product. Version is particularly useful for custom automation servers, so they can figure out what version of VFP they’re running in.
VERSION()
was seriously enhanced in Visual FoxPro and gained more functionality (the 4 and 5 parameters) in VFP 6. All the changes make it much easier to use in applications. We don’t have to check for specific strings to figure out if we’re in a distributed app; we just have to pass 2. The localization information makes it much easier to handle multilingual apps as well.
VFP 7 changed the VERSION()
function still more. In VFP 7, when you ask for the parsable build number using VERSION(4), you see something like: “07.00.0000.9147”. The groups of numbers represent the major build, minor build, a placeholder (always zero), and the build number. But in VFP 6 and earlier, the build number is in the third position, not the fourth, as in: “06.00.8862.00”. Who cares what the build number is, anyway? Well, you do. Particularly when the development team adds new features in a build, and you want to be sure your code is running in a version of FoxPro that can support the new features. VFP 6 Service Pack 3 was the main culprit here, adding lots of new features. Its build number is 8492.
In one of the few stunningly dumb additions to Visual FoxPro, the type of the return value of this function depends on which parameter you pass it. None, 1, 3, or 4 returns a character string, but passing a parameter of 2 or 5 returns a numeric value. We would be just as happy testing VERSION(2) = “2” as = 2, and this would make the function more consistent.
* At the end of an app, if we're in interactive VFP,
* we need to put some things back the way we found them.
IF VERSION(2)<>0
SET HELP TO cOldHelp
SET RESOURCE TO cOldResource
MODIFY WINDOW SCREEN
ENDIF