12.4.32    SCRLOOP

Description:   Execute an external script repeatedly (loop).  Downloads the file if it does not exist or a newer version exists on SCADA node.  Script will repeat until SCRSTOP.


Tcl:              SCRLOOP filename

                   SCRLOOP path/filename

                   SCRLOOP filename,frequency,repeats

                   SCRLOOP filename,frequency,0

                   SCRLOOP filename, 0.0, repeats

                   SCRLOOP {filename,  frequency,  repeats}


JScript:         SCRLOOP("filename");



VB Script:      SCRLOOP "filename"

                    SCRLOOP "filename,frequency,repeats"


Argument:     file name, path, frequency, repeats
frequency  range (0.025 - 400 seconds) , 0.0  uses  default  script frequency  = 0.5 sec.
repeats = 0 is forever until SCRSTOP

Returns:        none

See Also:       SCREXEC, source, MCREXEC


#Tcl example 1 - repeat forever

SCRLOOP playwarning.scr


#Tcl example 2 - loop script every 3 seconds until scrstop

SCRLOOP playwarning.scr,3.0,0


#Tcl example 3 - loop script every 3 seconds, repeat 20 times

SCRLOOP playwarning.scr,3.0,20


SCRLOOP will download the called script file if it does not exist, then enter the script into the program queue for that display to repeat continuously (loop) until the number of repeats is reached or until SCRSTOP command.  If repeats = 0 or no repeat specified, script will loop forever or until SCRSTOP. SCRLOOP does not execute immediately.  Instead, it is placed in the program queue, then executed after the script ends.  If the called script is not found on the client, it will be downloaded from the SCADA node.  This command is supported by screen scripts only.

The called script will begin to loop after the calling script ends.  Only a SCRSTOP command will terminate the looping  script permanently.  The keymacro <SCRSTOP> will stop the loop also, as well as the SCRSTOP command executed from any script from any display within the calling task (i.e. client window).

Only one script can loop per program space (i.e. per client window).

If no arguments are specified, then the script will loop at the default script frequency until SCRSTOP.  The default script frequency is 0.5 seconds. If spaces are used in the argument string then curly brackets {} or quotes"" are required.

The playwarning.scr  script called in example 1 above:

# Tcl countdown

MCISEND {play warn from 1}

set x [GETVAL analog1]

SETVAL analog1=[expr $x - 3]

If the looping script uses local screen tags not found on the new display, changing displays will temporarily stop the script from looping. (For example if analog1 in the above example is a screen tag, not a constant point). But, upon return to the display, the called script will continue to repeat without additional SCRLOOP commands since the local screen tags will become available to the script.