These functions all return information about the hardware or system configuration. Several of them don't provide accurate information.
nSpaceAvailable = DISKSPACE( [ cDrive [, nSpaceType ] ] )
cTotalSpace = SYS( 2020 )
cClusterSize = SYS( 2022 [, cDrive ])
These three functions provide information about the default disk drive. As the name implies, DISKSPACE()
tells you how much room is currently available. In versions prior to VFP 7, the only parameter is cDrive, the name of the drive. VFP 7 adds another parameter, which can have the value of 1 to return the total amount of space on the drive, omit the parameter or pass 2 to return how much free space is left, and 3 to return how much free space is left for the current user. DISKSPACE()
is handy when you want to copy a file to a disk and want to see if there's enough room for it first. SYS(2020) tells you the total size of the disk and SYS(2022) returns the number of bytes per cluster. These can also be useful when figuring out what's going to fit on a disk. There can be a maximum of 65,535 disk clusters on each volume under DOS or other FAT-based systems. On large volumes, these clusters can assume whopping sizes—16K or even 32K or larger! If you will be installing scads of dinky little files (like Visual FoxPro's BMPs and ICOs), you may want to consider warning the operator about how much space your files could waste!
The parameter cDrive was introduced in VFP 5 to save us the trouble of having to SET DEFAULT
TO every drive we want to test. It would have been nicer if they had added it for all the drive functions, though—SYS(2020) still reports on only the default drive. DISKSPACE()
accepts the cDrive parameter as "X", "X:" or "X:" but any other format confuses it. SYS(2022), on the other hand, ignores all characters beyond the first letter, and will happily report the cluster size of "Chihuahua" versus "Dalmatian." Another thing that's inconvenient is that the number displayed is so large that "?" returns scientific notation on gigabyte hard drives. Use ? TRANSFORM(DISKSPACE("c"),"999,999,999,999") to get a number you can view.
SET DEFAULT TO A: && A 3 1/2 drive
? SYS(2020) && Returns "1457664"
? SYS(2022) && Returns "512"
? DISKSPACE() && Might return 854016.000
cGraphicsCard = SYS(2006)
lColorCapable = IsColor()
These two return information about the graphics and color capabilities of the system. They are hangovers from the DOS days when monochrome monitors and EGA cards might mean you'd need to make some changes in your displays. SYS(2006) returns the type of graphics card and monitor in use. However, it appears it can't recognize anything more advanced than VGA in VFP 3, and just returns "Color/Color" in VFP 5 and later. ISCOLOR()
returns .T. if the system is color-capable. Under Windows, we let Windows take care of most of this stuff, but we can query SYSMETRIC()
for far more detailed information if necessary.
cProcessor = SYS(17)
SYS(17) returns, as a string, the processor type.
nFiles = SYS(2010)
This function returns 255. In FoxPro/DOS, it returns the files setting from CONFIG.SYS, but someone decided that, in Windows, you didn't need to know. Under Windows 3.1 or later, you always have 255 file handles available.
? SYS(2006) && Might return "Color/Color"
? ISCOLOR() && Might return .T.
? SYS(17) && Might return "Pentium"
? SYS(2010) && Returns 255
DriveType(), GetEnv(), Set Default, Set Display, SysMetric()