Salesforce

How Do I Iterate on a Series of Operations? (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

How Do I Iterate on a Series of Operations? (Magic xpa 4.x)

When you want to have a set of operations repeat themselves over and over, most programming languages have some kind of loop mechanism. In Magic xpa, this loop mechanism is the Block While operation. It can be entered in any logic unit.

As the name suggests, a Block While will execute while the condition that is controlling it is TRUE. In this example, we create a Block While operation to execute exactly 10 times.

LoopCounter()

The Block While operation has its own special function, called LoopCounter(). This function returns the number of times the loop has iterated, so you don’t have to create a special counter for each loop.

Creating a Block While operation


  1. Go to the logic unit you want to use.

  2. Press F4 (Edit->Create line). A blank line will appear below your cursor position, and your cursor will be located on a field at the left side of the new line.

  3. Type B. A Block operation will appear, with Block If and End Block operations, and the cursor will be positioned on the “If”.

  4. Type W. Now you have a Block While.

  5. Tab to the right, and zoom (F5 or double-click). This will bring you into Expression Rules.

  6. Enter the desired expression. You want an expression that will be FALSE when you want the loop to quit. In this example, we entered:

LoopCounter() <= 10

  1. which will be FALSE on iteration number 11, so the loop will execute exactly 10 times.

See also

The Online and Rich Client Samples projects (program LG05 and RLG05)

Reference
Attachment 
Attachment