

It will loop 10 times, increasing the value of MyValue by 1 each time in total increasing MyValue by 10 each time it is run:Įxample 2: A common use case of a FOR loop would be to reset a group of tags which all have similar names, only differing by a number at the end. Begin again at step 2, comparing StartingNumber to FinalNumberĮxample 1: The following script is a simple example of using a FOR loop. When it gets to NEXT it will then increment the value of VARIABLE by 1.Ĥ. If VARIABLE's value is less than or equal to FinalNumber it will then run the code within the FOR loop ("Steps you want to complete")ģ. If VARIABLE's value is now greater than FinalNumber it will exit the loop.Ģ. VARIABLE will be set to the StartingNumber value.Ģ. Due to the script running synchronously, and pausing all other execution, loops like this should be used sparingly.įOR = TO ġ. The workarounds listed above should be used after first considering the alternatives.Ģ. If these limitations are a concern, you should first look for alternative approaches, such as writing the script in a different way, or moving this functionality somewhere else, such as into a PLC.
#Intouch view script debugger software#
Workaround:This timeout period can be modified from the intouch.ini file, by adding "LoopTimeout = X", where X is the number of seconds you would like the software to wait.ġ. If the script is still running after this timer elapses, the script execution will be terminated. To avoid this problem InTouch has a timer that, by default, will only allow a script to execute for a maximum of 5 seconds. Anytime a loop is used in a script, there is the risk of it running indefinitely if there is an error in the script. Workaround: You can place the script in an asynchronous QuickFunction script, but be aware that QuickFunctions do have some additional limitations not seen in other script types.Ģ. This means that while a FOR loop is running InTouch graphics will not update, no other scripts will run, and IO communication will not occur. FOR loops run synchronously, which means that everything else within InTouch will stop and wait for the FOR loop to complete.

This is typically useful when you have multiple tags with similar names, and need to perform an action on all of them.īefore using a FOR loop it is important to understand the limitations imposed by InTouch.ġ. The FOR loop allows you to run a set of steps repeatedly, a specific number of times.
#Intouch view script debugger how to#
This article will describe how to use one, as well as the limitations. When scripting in InTouch it can be useful to loop through a set of steps repeatedly.
