Control Flow
The contents of a Linx function is executed from top to bottom.
In Linx control flow statements are implemented as functions. The Linx plugin contains DoWhile, ForEach, IfElse and TryCatch. They work exactly like their programming counterparts.
ForEach loops through any list and exposes each item in an execution path. To try it:
- Create a list and call it Names.
- Drag a ForEach from the Linx plugin.
- Set the List property to Names (using the dropdown).
The ForEach shows an execution path called Loop. This path will be executed once for each item in the List. To see it working:
- Add a couple of items to Names.
- Add the File plugin.
- Drag the TextFileWrite function into the box below Loop.
- Set the File path property.
- Set the Contents property to ForEach.Loop by selecting it from the dropdown.
Click DEBUG to run the Function and see the result.
DoWhile and IfElse use expressions to control the program flow. To try DoWhile:
- Add an Integer to the Function and name it Counter.
- Add a DoWhile and set its Condition property to Counter < 5. Use the Expression Editor in the dropdown to make this easier. DoWhile will keep on executing while the Condition is true.
- Add a SetValue to the Loop and set its properties to add 1 to Counter each time it executes.
Click DEBUG to run the Function and see the result.