Statement: Condition, Type: Initial
While
Format: While support-condition { support-condition... }
begin-identifier
end-identifier
where
-
support-condition = one or more of any valid series of supporting condition identifiers to complete a condition statement.
-
begin-identifier = the begin keyword identifier to denote the beginning of a condition block
-
end-identifier = the end keyword identifier to denote the end of a condition block.
Description
The While identifier reads the initial support-condition to build a condition statement. Depending on the initial support-condition one or more supporting condition identifiers may be required. Once all required support-conditions are read and validated by the compiler, a condition block is created that contains two logical outcomes: true or false.
When the outcome of the condition is evaluated as true the program control is passed to the body of the condition block. From there, the system will then execute all action and condition statements inside of the condition block between the begin-identifier and end-identifier. At this point, program control exists the condition block. If an Exit identifier is encountered inside the condition block, the program control will be passed back to the main view awaiting for another spin to be processed.
If the outcome of the condition is evaluated as false, the program control will completely skip the entire condition block and program control will be passed to the location just past the end-identifier of the condition block.
Condition Block
A condition block of a condition statement is identified with a begin-identifier and end-identifier that goes with the condition statement. Just after the complete condition statement, a begin-identifier is required to tell the compiler that this is the beginning of the condition block. For every begin-identifier there must be an end-identifier to denote the end of the condition block.
The condition statement, If has the same functionality as the While statement. Both are provided for User preference |
Example 1
When we initialize a new session, we want to initialize some data and get some input data from the user. The supporting condition identifiers, starting and new Session instructs the compiler to evaluate this condition statement as true of when the user initiates a new session. The following example will perform this task.
RX Script | Copy Code |
---|---|
While Starting a new Session begin Call "initialize" Call "get inputs" Exit end |
Example 2
We want to determine if our win goal have been met by 25 units and if so, display a message to the User and stop the session. The supporting condition identifiers, record data, > (greater than symbol) and integer instructs the compiler to evaluate this condition statement as true only when the value in the data record win goal is greater than our target goal of 25 units. The following example will perform this task.
RX Script | Copy Code |
---|---|
While Record "win goal" data > 25 units begin Display "You have reached your win goal." Stop Session end |