DiskSpace(), Sys(2020), Sys(2022), Sys(2006), IsColor(), Sys(17), Sys(2010)
These functions all return information about the hardware or system configuration. Several of them don't provide accurate information.
Usage |
nSpaceAvailable = DISKSPACE( [ cDrive [, nSpaceType ] ] ) cTotalSpace = SYS( 2020 ) cClusterSize = SYS( 2022 [, cDrive ]) |
You'll want to test for reasonableness in the return values of SYS(2022), and watch for differences between the versions of VFP. Ted's CD-ROM had a perfectly acceptable 32,768 bytes per sector—as long as there was a disk in the drive. Remove the disk, and the same function under VFP 3 returns 14,988,640 bytes per sector—a bit too high to be likely! VFP 5 reported DISKSPACE() of –1 and SYS(2020) of 0, and SYS(2022) generated error 1907, "Drive specifier is invalid." VFP 6 returns similar results, with an error 1002, "Input Output failure," under Windows NT 4. Testing this for VFP 7 opened quite a can of worms. Seems that the drive type, operating system, and even VFP's service patches all seem to play a role in what happens. When there's a disk in the CD-ROM drive, SYS(2020) returned a value of 408656384 in VFP 7 prior to SP1, and 0 with SP1. When there's no disk in the drive, things get a little strange. Under Windows 2000, you'll get a SYS(2020) of –1, but XP raises a Windows error message dialog telling you there's no disk in the drive, and after pressing Continue, it returns –1. SYS(2022) is even flakier. It seems that, after some testing on about 10 different drives, that a CD, CD/RW, or ZIP drive raises error 1002, "Input/Output operation failure,", while a CD-DVD drive raises error 108, "File is in use by another". As with SYS(2020), Windows XP thoughtfully (not!) raises the error dialog explaining you should put a disk in the drive, and upon pressing Continue, returns "Input/Output operation failure." The number of kinds of test CD drives at Hacker Labs is limited, and we think there may be more possibilities based not only on the kind of drive, but also on the specific driver. The bottom line is that you can't count on the error messages returned for SYS(2020) and SYS(2022) in VFP 7 for removable drives. Your best bet: Check out the DRIVETYPE() function to check for a removable drive before using this command. If you need very accurate information, you should check out the Windows API function, GetDiskFreeSpaceEx to circumvent these problems. |
Example |
SET DEFAULT TO A: && A 3 1/2 drive ? SYS(2020) && Returns "1457664" ? SYS(2022) && Returns "512" ? DISKSPACE() && Might return 854016.000 |
Usage |
cGraphicsCard = SYS(2006) lColorCapable = IsColor() |
Usage |
cProcessor = SYS(17) |
On the 32-bit versions of Windows, SYS(17) worked just fine—until the Pentium clones came along. Chips at the Pentium-class or greater all return "Pentium," even if the chip is, say, an AMD Thunderbird. In VFP 3 under 16-bit Windows, SYS(17) on a Pentium returns "80486"—not what the client who just spent megabucks for a new machine wants to see. It's not FoxPro's fault, though—it's a Windows thing. |
Usage |
nFiles = SYS(2010) |
Example |
? SYS(2006) && Might return "Color/Color" ? ISCOLOR() && Might return .T. ? SYS(17) && Might return "Pentium" ? SYS(2010) && Returns 255 |
See Also |
DriveType(), GetEnv(), Set Default, Set Display, SysMetric() |