OSOTRX40 - REX0040 ERROR WHEN USING THE REXX TIME() FUNCTION 04/26/96 ======================================================================= REX0040 Error when Using the REXX Time() Function ======================================================================= Please Read Entire Document for Full Explanation of Procedure ------------------------------------------------------------- DESCRIPTION When a REXX Time("E") or Time("R") function is issued, the following error message is received: REX0040 Incorrect call to routine. Time("R") will reset the timer clock, and Time("E") will return the time elapsed since the last reset. This problem usually occurs in programs that log on to multiple local area network (LAN) domains and then try to record the amount of time spent on each logon; however, the problem also can occur on any system that resets the timer or checks the elapsed time. RESOLUTION Make sure the current system time is not earlier than the last reset. For example, consider a large LAN/WAN (wide area network) environment with multiple domains. The failing program logs on to multiple domains, does whatever it needs to do, and then records the time spent on that logon into a log file. The program loops through logging on to each domain, which looks (conceptually) something like the following. Note: This is not actual code. Server.1 ... Server.n Do Logon to Server.n /* Server resets the time */ Call Time "R" /* Resets the timer, Time */ Call CopyFiles ElapsedTime = Time("E") /* Gets the elapsed time fine */ Loop This is what can happen: 1. The logon to Server.n sets the clock to 2 p.m. 2. The Timer is reset to 2 p.m. 3. Files are copied. 4. Elapsed time is called at 2:10; Current Time is compared to the time stored when the Reset was done at 2 p.m.; the time returned to the ElapsedTime variable is 10 minutes. 5. The program loops to the next Server.n. 6. This Server.n (the next server in the array) sets the time to 1 p.m., which is earlier than the 2 p.m. stored with the Reset. 7. Time "R" is called to reset the time and return the elapsed time from the last reset; however, the time is now a negative number, which causes the REX0040 error because the function cannot handle negative time. Possible solutions are: * Do not query the current Time(). * If the current Time() is less than the last reset time, do not do a comparison. * If running on a requester, turn off the requester's time-synchronization function. ______________________________________________________________________ IBM disclaims all warranties, whether express or implied, including without limitation, warranties of fitness and merchantability with respect to the information in this document. By furnishing this document, IBM grants no licenses to any related patents or copyrights. Copyright (c) 1994, 1996 IBM Corporation. Any trademarks and product or brand names referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark information.