Smart Buttons
Controls/XML Elements

Loops <ForEach>

A loop is a sequence of statements that is specified once, but can be carried out several times in succession.

The code "inside" the loop (the body of the loop is everything in <Action> element) is obeyed either:

  • A specified number of times (For Loop)

  • Once for each of a collection of items (ForEach Loop)

    For example, you can have a collection of phone line numbers (2;4;5), and you want to perform the same action (cancel) for each phone line.

Configuring

It is recommended to configure using the fields in the Loops XML Generator. However, you can also configure using XML.

Configuring with the Loops XML Generator

To configure with the Loops Editor:

  1. Open the Smart Buttons Editor to create a script.

  2. Click Loops <ForEach> to display the Loops XML Generator.


  3. In Loop type, select either:

  • For Each loop

    A control flow statement for traversing items in a collection. In other words, a For Each loop essentially says do this set of code for every element from the collection, rather than do this function x times.


  • For Loop

    A control flow statement for traversing items specific number of times. In other words, a For loop essentially says do this set of code x times.

  1. Click SUBMIT.

Configuring with XML

You can also enter all associated XML directly into the Smart Buttons editor.

Tip! You can add the XML code directly to the editor by dragging and dropping the blue button for this control.

ForEachLoop

A control flow statement for traversing items in a collection. In other words, a For Each loop essentially says do this set of code for every element from the collection, rather than do this function x times.

Copy
<ForEach ElementsList="">
<ElementsList>
</ElementsList>
<Action EasyMode="False">
</Action>
</ForEach>
Elements

The <ForEach> element contains two child elements: <ElementsList> and <Action>.

Examples
ForLoop

A control flow statement for traversing items specific number of times. In other words, a For loop essentially says do this set of code x times.

Copy
<ForEach>
<ForStatement StartNumber="" EndNumber="" Step="" />
<Action></Action>
</ForEach>