Saflet101Loop
Loop Structure
With the flow based logic structure in Saflet, you can easily create loops. In this walkthrough, we will go over setting up a loop with a terminating condition.
Walkthrough
Download Saflet Used in this Walkthrough
For this walkthrough; you will need to be connected to a SafiServer (see Connection to SafiServer from SafiWorkshop). You will also need to create a Project/Saflet with the Custom Initiator selected as the starting initiator (See: Creating a Project and Saflet)
First create a Local variable with the name of counter, type of Integer, and an initial value of 0. We'll use this variable to keep track of the loops.
Next, add the following ActionSteps:
- (1) IfThen
- (2) DebugLog
- (1) Assignment
Then connect them like so:
In the IfThen ActionStep; enter the following script for the Boolean field:
counter >= 3;
Now in the Assignment ActionStep; set the variable to counter and the Value to the following script:
counter + 1;
Set the message field of the DebugLog step connected to the IfThen false output to the following script:
"The count is currently:" + counter;
...and set the message field of the DebugLog step connected to the IfThen true output to the following script:
"Done with looping at:" + counter;
Your Saflet should be clear of errors:
like the following:
Save and Publish the Saflet
Launch the Saflet with the Custom Initiator Client (Send):
You should see the following in the Console pannel:
As with any Saflet, if you want to see more detail about whats happening: use the Debug feature
SideBar
User Login
Comments (