This command performs timer-related operations.
second [option] [argument]
This command performs timer-related operations.
Start a timer from zero. This timer is independent from any timer started by sec -ab.
Syntax: sec -ab
Starts a timer. Use sec -ae and sec -at to stop the timer started by sec -ab.
Same behavior as sec or sec -i, but uses a more precise method. A timer started with sec -ab is independent of a timer started by the sec command, or reset by sec -i.
Syntax: sec -ae variable
Put the elapsed time in seconds since sec -ab or last issue of the sec -ae command into variable.
Syntax: sec -at variable
Put the elapsed time in seconds since last sec -ab call into variable, ignoring any sec -ae commands.
Syntax: sec -e variable
Get the elapsed time from the last time the sec command was issued.
The time resolution of the sec -e option is about 15ms. Sec -e is called by the watch macro such that:
sec; ... script; sec -e v1; v1=;
Gives the same result as:
sec;
... script;
watch;
provided the script being executed is identical.
Syntax: sec -i
Reset the timer to zero.
Syntax: sec -p sec
Pause for the specified number of seconds. The current script is suspended and then continued after the time elapses. During this period, all other processes continue to execute.
Syntax: sec -poc sec
(Origin 8 SR4) Pause up to the specified number of seconds to wait for Origin OC startup compiling to finish.
To check if Origin C environment is ready, you can use run.isOCready()
, as shown below:
sec -poc 3; if(run.isOCready() == 0) { type "waited 3 sec, but OC is still not ready, or it just failed"; break 1; } type "ok, can continue now";
This is very useful when you need to run some X-Function when Origin starts, as there is a separate thread that loads and prepare Origin C which might take a fraction of a second, but neverthless the main thread will still need to wait during that time.
Syntax: sec -pw GraphName
Pause execution of remaining lines until GraphName has finished redrawing.
Minimum Origin Version Required: 9.0 SR0
Syntax: sec -sn
sec -sn to prevent Windows sleep; and sec -sn 0 to allow sleep
Syntax: sec -w sec
Pause for the specified number of seconds. Similar to the -p option but does not allow other processes to run.
Example 1 The following script measures script execution time:
def HowLong { sec; //get current system time %1; //execute script typed as argument to HowLong macro sec -e time; //get elapsed time since the sec command type (Elapsed time = $(time) sec.); //type time to Script window }
If you now supply the HowLong macro with a script for an argument, for example:
HowLong {repeat 100 (i+=1)};
then script execution time is measured, and the result is printed to the Script window:
Elapsed time=0.384 sec.