![]() | ![]() | ![]() | ![]() | ![]() |
GetFileTimeStamp() |
This is a rexx function provided by PPWIZARD. This routine (like all PPWIZARD extensions) can be used with any operating system supported by PPWIZARD.
This function takes a single parameter ( the name of the file we wish the date/time imformation of).
If successful this routine returns a decimal number of the form "YYYYMMDDHHMMSS". The returned number can be compared with others to determine the newest file etc. You can substr() etc to transform the result into whatever format you desire.
If the call fails (for example if the specified file does not exist) then a WARNING is generated and a return code of "-1" is returned. This assumes you did not tell PPWIZARD to die!
You can determine the day of the week or age of a file by passing the return value to BaseDate().
Example |
The following example shows how the date/time of a file can be retrieved and converted into whatever format you wish. Note that in the following macro I was careful not to redefine any variables and that a file not found is treated as a fatal error. I generally prefer to use #DefineRexx to code a macro such as that shown below however this one demonstates how it can be done with very little knowledge of rexx at all.
#define GetFileDateTime \ #DependsOn INPUT "{$File}" -\ #evaluate TmpDateTime ^GetFileTimeStamp("{$File}");^ -\ #if <$TmpDateTime> = -1 -\ #error ^The file "{$File}" was not found.^ -\ #elseif -\ ;--- Reformat the retrieved information ------------------- -\ #evaluate TmpDate ^substr('<$TmpDateTime>', 7, 2) || '/' || substr('<$TmpDateTime>', 5, 2) || '/' || left('<$TmpDateTime>', 4)^ -\ #evaluate TmpTime ^GetAmPmTimeFromHhMmSs(substr('<$TmpDateTime>', 9))^-\ -\ ;--- Output the information ("DD/MM/YYYY at HH:MM:SSam") -- -\ <$TmpDate> at <$TmpTime> -\ #undef TmpDate -\ #undef TmpTime -\ #endif -\ #undef TmpDateTime ;--- Use my macro to get a timestamp ------------------------------------- <P>The date/time stamp of "C:\AUTOEXEC.BAT" is "<$GetFileDateTime File="C:\AUTOEXEC.BAT">".
![]() | ![]() | ![]() | ![]() | ![]() |