The function TIME generates a syntax error if called with the parameter E or R if the elapsed time is negative (the stop time is before the start time). Note that this error is fixed in Object-Oriented REXX -- but not in Classic REXX from WARP 4.
Example:
/* simple code to show the error in the function time() */
/* install an error handler */
signal on Syntax
/* get the current time */
thisTime = time( "N" )
/* calculate the time 1 hour _before_ now */
testTime = substr( thisTime,1,2 ) - 1 || substr( thisTime,3 )
say "Current time is:" thisTime
say "Now reseting the timer ..."
call time "R"
/* now setting the stop time _before_ the start */
/* time */
say "Now setting the time to" testTime "..."
"@time" testTime
say "The time now is:" time()
say "Now retreiving the elapsed time via time(E) ..."
say " (--> This will generate a syntax error!)"
say "Elapsed time is" time("E")
ProgramEnd:
say "Now resetting the time to the correct value ..."
/* get the current time */
thisTime = time( "N" )
/* set the correct time */
"@time" substr( thisTime,1,2 ) + 1 || substr( thisTime,3 )
say "Current time is:" time()
exit
/* error handler */
Syntax:
say "*** Syntax error occured in line:" sigl
say " Condition(D) is" condition(D)
say " Condition(C) is" condition(C)
say " rc is" rc
say " The error message for" rc "is:"
say " " errortext(rc)
/* jump to ProgramEnd to correct the time */
signal ProgramEnd