PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: GetFileLineBeingProcessed()[Next]: GetId()
\ -> Rexx -> Inbuilt PPWIZARD Functions -> GetFileTimeStamp()

GetFileTimeStamp()

This is an inbuilt function function provided by PPWIZARD.

This function takes a single parameter (the name of the file we wish the date/time information of).

  1. File Name
    This is the name of the file we wish the date/time information of.

  2. If File Doesn't Exist
    This optional value tells PPWIZARD what to do if the file doesn't exist. If you pass "D" then PPWIZARD will terminate, if you pass "Q" then PPWIZARD will ignore this or "W" (or anything else) to cause PPWIZARD to generate a warning.

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.

Note that it is now much easier to get a formatted time using the FileQueryDateTime() routine.

#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">".


email me  any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Search][Prev]: GetFileLineBeingProcessed()[Next]: GetId()


PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Sunday November 05 2017 at 10:00am