CREATE TRIGGER

Seconds(), Sys(2)

SECONDS() returns a numeric value of the number of seconds since midnight, with a resolution of one millisecond. SYS(2) returns a character string of the same number, formatted as five digits with no decimal places.

Usage

nRetVal = SECONDS() cTime = SYS(2)
Very useful for benchmarking the time to complete a task—record the start time, do the task, then subtract the start time from the end time to calculate the duration of the task. Don't confuse this with the SEC() function used to extract the seconds portion of a datetime.

The SECONDS() function grabs the time when FoxPro starts and stores it in some hidden nook or cranny. Changing the system time while FoxPro is running is not reflected in the SECONDS() function, although TIME() and DATETIME() do seem to pick it up.


Strangely enough, the SECONDS() function, while ignoring other changes, does note that midnight has passed during the current session and resets SECONDS() to zero. This can be very useful if you are capturing seconds since midnight in an application that might need to run for several days. This was a notorious 2.x bug, squashed finally in 3.0.


SYS(2) does reflect changes made to the system time while Visual FoxPro is running, although we don't advise doing this—it can make it awfully difficult to determine which source code is the most recent when the time keeps shifting! SYS(2), like SECONDS(), will reset on the stroke of midnight.

Example

lcStopTime = SYS(2) lnStartTime = SECONDS()

See Also

DateTime(), Sec(), Time()


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net