(view source code of chksize.rex as plain text)
/* ChkSize.rex, Version 2.00 for OS/2 and Windows */
/* Display blank line */
Say
/* Initialize RexxUtil */
If RxFuncQuery( "SysLoadFuncs" ) <> 0 Then Do
Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs"
Call sysloadfuncs
End
/* Read command line parameters */
Parse Upper Arg commandline
/* Check parameters' validity */
Parse Value commandline With '"'filespec'"' cmpsize dummy
If filespec = "" Then Parse Value commandline With filespec cmpsize dummy
/* Check for the correct number of parameters */
If dummy <> "" Then Call Syntax
If cmpsize = "" Then Call Syntax
/* Second parameter should be a whole number */
If DataType( cmpsize, "W" ) <> 1 Then Call Syntax
/* Check if specified file exists */
Call SysFileTree filespec, "files.", "F"
/* If it doesn't exist, or if wildcards were used, */
/* or if a directory was specified, display help */
If files.0 <> 1 Then Call Syntax
Parse Upper Value files.1 With . . actsize . file
file = Strip( file )
If FileSpec( "N", file ) <> FileSpec( "N", filespec ) Then Call Syntax
/* Compare actual and specified file size */
Select
When actsize = cmpsize Then Do
say "Sizes match exactly"
errorlevel = 0
End
When actsize > cmpsize Then Do
say "Actual file size exceeds specified size"
errorlevel = 1
End
When actsize < cmpsize Then Do
say "Actual file size less than specified file size"
errorlevel = 2
End
Otherwise errorlevel = 3
End
/* Normal program termination, use errorlevel to return result */
Exit errorlevel
Syntax: Procedure
Say "ChkSize, Version 2.00 for OS/2 and Regina Rexx"
Say "Checks if file size matches specified file size and returns an"
Say "errorlevel accordingly"
Say
Say "Usage : CHKSIZE <filespec> <minimum_size>"
Say
Say "Returns : Errorlevel 1 if greater than specified file size"
Say " Errorlevel 0 if equal to specified file size"
Say " Errorlevel 2 if smaller than specified file size"
Say " Errorlevel 3 if invalid parameters were specified"
Say
Say "Do not use wildcards in <filespec>."
Say "<filespec> must be enclosed in double quotes if it contains spaces."
Say
Say "Written by Rob van der Woude"
Say "http://www.robvanderwoude.com"
Exit 3
Return
page last modified: 2024-04-16; loaded in 0.0076 seconds