Protect Against Infinite Looping

From Pengower
Jump to: navigation, search

Whenever you use any of the Action Script iterative statements in order to process a block of code a number of times; be mindful of the danger of infinite looping and be sure you implement some kind of safeguard against this.

In the following example the variable fuse is such a safeguard.


1
2
3 Set counter = 1
4 Set jumpOut = 0
5 Set fuse = 0
6
7 Loop
8 Set fuse = fuse + 1
9 If (fuse > 100)
10 Report = "<span style='color: red; font-weight: bold;'>Looping error detected.</span>"
11 Output = frm
12 Return_Ok
13 EndIf
14
15 Set emailTemplate = emailTemplateArr[counter]
16
17 If emailTemplate["Name"] = "OHA Initiate"
18 Set jumpOut = 1
19 EndIf
20
21 Set counter = counter + 1
22 Until ((jumpOut = 1) OR (counter > emailTemplateCount ))


See Also

How to Create Action Scripts

How To Define a Long Running Script

Script Action Library

Run Script