Control Flow(3.1)
The following keywords are used for controlling the execution flow in the APL programming language.
Keyword | Description | Example |
---|---|---|
break | Terminates the execution of the current loop. | while(i++ < 10) { if( i == 5 ) { break; } } |
continue | Terminates execution of the current iteration of the loop, and continues execution of the next iteration. | while( i++ < 10) { if( i%2 == 0 //your code { else { continue; } } } |
for |
The
Creates a loop that consists of three expressions. The first expression performs initialization of a variable that is used for counting iterations. A variable declared in this expression is only available in the scope of the for loop. The second expression contains a condition that must evaluate to true or false. The loop iterates until the condition evaluates to false. The third expression is evaluated at the end of each loop iteration, before the next evaluation of the condition. This is typically used to update or increment the counting variable in the condition. | list<int> listOfInts = listCreate(int,1,2,3); for (int i: listOfInts) { //your code }  list<string> listOfStrings = listCreate(string,"1","2","3"); for (string s: listOfStrings) { //your code } for( int i=0; i<10; i++ ) { } |
if else | Used to execute code with conditions. | if (myVar == "ABC") {// do_this} else {// do_that} |
return | Stops the execution of the current function block. | if ( ANumber == null ) { return;} |
while | Loops while condition is true. Note! If the APL code generates an infinity loop it can be stopped by, in the Workflow Monitor or Execution Manager, selecting the Stop button and Stop Immediate. This will however not work if the loop is running in the | while( i < 20 ) { // do_stuff} |
switch case | Allows an expression to be tested for equality against a list of values or types, where each of these is a case. The cases are evaluated against the expression in order, from top to bottom. After a match, the remaining cases will not be evaluated. It is possible to have one case with multiple values. A switch statement can have an optional default case, Testing values: The value for a Testing types: The type for a | // Testing values switch (str) { case "one", "two" { //Testing container types
 |