Brian Dunning's FileMaker Custom Functions

StopwatchMilliseconds ( ctrlStartTimeLapListStopClear ; prefixText ; variableName )

Creates and manages a value list variable to track milliseconds with full stopwatch controls: Start, Time, Lap, List, Stop, or Clear.

  Average rating: 3.3 (4 votes) Log in to vote

Lewis Lorenz   Lewis Lorenz
Lorenz Companies
http://www.LorenzCom.com

Share on Facebook Share on Twitter

  Sample input:
StopwatchMilliseconds ( "start" , "Loop tracking started:" , "" )
StopwatchMilliseconds ( "lap" , "Looping run begun:" , "" )
StopwatchMilliseconds ( "lap" , "Looping process:" , "" )
StopwatchMilliseconds ( "lap" , "Looping process:" , "" )
StopwatchMilliseconds ( "lap" , "Looping run ends:" , "" )
StopwatchMilliseconds ( "stop" , "Loop tracking stopped:" , "" )

$$StopwatchMilliseconds
  Sample output:
0
30855
43240
48818
68490
94609

63670563400527
63670563495136
Loop tracking started:0
Looping run begun:30855
Looping process:43240
Looping process:48818
Looping run ends:68490

Loop tracking stopped:94609

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

StopwatchMilliseconds ( ctrlStartTimeLapListStopClear ; prefixText ; variableName )

Creates and manages a value list variable to track milliseconds.
ctrlStartTimeLapListStopClear controls stopwatch functions. Full word required: Start, Time, Lap, List, Stop, or Clear.
prefixText prepends text to Start, Lap, and Stop valuelist elapsed time values.
variableName specifies $ or $$ variable name. If empty variable name defaults to "$$StopwatchMilliseconds".

Commands in parameter ctrlStartTimeLapListStopClear control the function's access to the variable. Control options:
"Start" resets the variable with a new current UTC start time as the 1st value and sets the 2nd value to 0. Returns 0.
"Time" returns the current elapsed time since the start time, without appending the value to the variable. Returns elapsed milliseconds.
"Lap" appends the elapsed time value to the variable. Lap may be prefixed with the prefixText parameter. Returns elapsed milliseconds.
"List" returns a value list of the Lap values that were appended to the variable by the Start, Lap, and Stop commands.
"Stop" sets the 2nd variable value to the current time and stops further Time and Lap commands. Returns the elapsed milliseconds since starting.
"Clear" empties the variable. Returns 0.

Variable values 1 and 2 are obtained from the function Get ( CurrentTimeUTCMilliseconds ) which can be displayed as Timestamps with the GetasTimestamp () function:
GetAsTimeStamp ( Get ( CurrentTimeUTCMilliseconds ) / 1000 ).
Change the UTC times to local time by applying the UTC offset to these values:
Local UTC offset: Get ( CurrentTimestamp ) - Floor ( Get ( CurrentTimeUTCMilliseconds ) / 1000 ).

Example:

StopwatchMilliseconds ( "start" , "Loop tracking started:" , "" ) = 0
StopwatchMilliseconds ( "lap" , "Looping run begun:" , "" ) = 30855
StopwatchMilliseconds ( "lap" , "Looping process:" , "" ) = 43240
StopwatchMilliseconds ( "lap" , "Looping process:" , "" ) = 48818
StopwatchMilliseconds ( "lap" , "Looping run ends:" , "" ) = 68490
StopwatchMilliseconds ( "stop" , "Loop tracking stopped:" , "" ) = 94609

$$StopwatchMilliseconds = 63670563400527
63670563495136
Loop tracking started:0
Looping run begun:30855
Looping process:43240
Looping process:48818
Looping run ends:68490

Loop tracking stopped:94609

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.