|
|
|
|
|
- Code to run
- Exiting from a WHILE loop
- Loop without end
- Running the next iteration
- Composite condition
WHILE statement In french: TANTQUE
In a WHILE statement, the expression is evaluated at the beginning of the statement block. The process loops as long as the condition expression is True. The program will exit from the statement block when the condition is False. MyList = INIRead("Examples", "", "", INIFile)
Keyword = ExtractString(MyList, nb, CR)
WHILE Keyword <> ""
nb = nb + 1
ExplName = INIRead("Projects installed", Keyword, "", INIFile)
Keyword = ExtractString(MyList, nb + 1, CR)
END
Syntax
"WHILE" condition Hide the details
WHILE <Condition> <Action if condition is True> END
<WHILE>: Marks the beginning of the statement block. <Condition>: Condition to check. <Action if condition is True>: Action to perform if the condition is True. <END>: Marks the end of the statement block.
Loop with exit according to a "WHILE" condition Hide the details
LOOP ... DO WHILE <Condition>
<LOOP>: Marks the beginning of the statement block. <DO WHILE>: Marks the end of the statement block. Used to exit from the statement block. The lines of the loop found before this statement are run. Remarks The code to be executed is between the WHILE and END statements. Exiting from a WHILE loop Several statements are available: - RETURN: Exit from the WHILE loop and exit from the current process (or procedure).
- RETURN: Return a status report to the calling process. Exit from the WHILE loop and exit from the current process (or procedure).
- BREAK: Exit from the WHILE loop and run the rest of the current process.
Close is used to exit from the WHILE loop and to close the current window. When compiling the project, a WHILE loop without an obvious end ( BREAK, RETURN or RETURN statement missing) is signaled by a warning. Running the next iteration To directly run the next iteration without ending the code of the current iteration, use the CONTINUE statement: WHILE <Condition> ... IF <Condition> THEN CONTINUE // Go back to the WHILE keyword ... END The AND and OR keywords are used to perform logical operations and to create composite conditions. For example: WHILE Price < 100 AND ProductType = "AA"
NumProduct ++
END
WHILE Price > 100 OR Price < 500
NumProduct ++
END
The conditions made of AND and OR are entirely evaluated. For example: Even if the first condition (A1 > 10) is false, the second condition (B1 < 20) will be checked. Optimizing the evaluation of composite conditions: Use the _AND_ and _OR_ keywords. If the first condition is false (A1 > 10 in our example), the second condition (B1 < 20 in our example) will not be checked.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|