I am trying to build a library of vbscript functions and I would like to build in error checking but I am running into a problem, or at least something I don't understand. I want the function to verify the variables it is passed before it begins. The first thing I want to check is that all the variables are specified, but when I tried to test for missing variables I found the error seems to be generated when the function is called but before control is passed to it
' Sample program to demonstrate CheckFreeSpace Functio
if (CheckFreeSpace ("c:", 1200000)) the
wscript.echo "ROOOOOOOMMMMMMMY!
els
wscript.echo "tight
end i
' End Sample program to demonstrate CheckFreeSpace Functio
Function CheckFreeSpace(drvPath, MBNeeded
' usage: if (CheckFreeSpace("c:", 12)) then something
' checks for free space. If the free space on the drive exceeds the
' amount requested returns true. Otherwise it returns false
' the MBNeeded is megabytes needed. d.FreeSpace returns byte
' so we devide by 1,000,000 to get megabytes, and yes I know abou
' using 1024, but 1,000,000 gets the same number as the DIR command
Dim fso, d,
Set fso = CreateObject("Scripting.FileSystemObject"
Set d = fso.GetDrive(fso.GetDriveName(drvPath)
if (d.FreeSpace/1000000 > MBNeeded) the
CheckFreeSpace = Tru
els
CheckFreeSpace = Fals
end i
End Function