Function to Calculate Elapsed or Accumulated TimeID: Q115055 2.50 2.50a 2.50b 2.60 3.00 | 2.50 2.50a 2.50b 2.60 | 2.50b 2.50c
The information in this article applies to:
SUMMARYAlthough the TIME() and SECONDS() functions in FoxPro return the current time and seconds elapsed since midnight, respectively, there are no intrinsic functions within FoxPro to directly perform arithmetic operations on time values. The user-defined (UDF) function shown below makes it possible to add or subtract values returned by the TIME() function or those entered manually in the standard hours:minutes:seconds format.
MORE INFORMATIONThe following function is used by the first set of code samples found below it:
Sample Code
The following program demonstrates a FoxPro for Windows-specific
implementation of the TimeCalc() function, which tracks the time since the
current FoxPro session began. The timer can optionally be reset. This
example uses a program file called by the CONFIG.FPW file when FoxPro is
started to initialize the variables and set keytraps for displaying and
resetting the timer.
To have the program load automatically when FoxPro starts, modify the
CONFIG.FPW file to include the following line:
To use the timer, press F5 to display how long FoxPro has been running. You
can display the elapsed time at any time during the session by pressing F5.
If you are repeating a specific action and each action must be timed separately (such as data entry or phone call tracking), press F4 (or issued it programmatically with the KEYBOARD command) to reset the timer at the beginning of the action. When you have completed the action, press F5 to display the elapsed time for that action. If the timer has not been reset, you can display the entire session time by issuing F5 within an ON SHUTDOWN routine. If individual actions must be tracked as well, you can assign an additional variable in the TIMETRAK program to track the entire session. Additional reference words: VFoxWin 3.00 FoxMac FoxDos FoxWin 2.60 timing stopwatch lap KBCategory: KBSubcategory: FxenvConfigfp
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |