Difference between revisions of "Core.Actions.Loop.WhileLoop"

From emotive
Jump to navigation Jump to search
(Created page with "Category:Core == Classification == {{ClassificationActivity | WhileLoop | Loop that is iterated until the condition evaluates to false. | Action | Core|OTX Core libr...")
 
Line 2: Line 2:
 
== Classification ==
 
== Classification ==
 
{{ClassificationActivity | WhileLoop | Loop that is iterated until the condition evaluates to false. | [[Action]] | [[Core|OTX Core library]] | [[Core related actions]] | - | - }}
 
{{ClassificationActivity | WhileLoop | Loop that is iterated until the condition evaluates to false. | [[Action]] | [[Core|OTX Core library]] | [[Core related actions]] | - | - }}
 +
 +
== OTL Syntax ==
 +
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 +
// While (do)
 +
while (BooleanTerm) : WhileLoopName
 +
{
 +
  ...
 +
}
 +
 +
//Do while
 +
do
 +
{
 +
  ...
 +
} while (BooleanTerm) : WhileLoopName
 +
</syntaxhighlight>
  
 
== Description ==
 
== Description ==
Line 16: Line 31:
 
{{TableRowPropertie2| Test | [[Boolean]] | [[Term]] | - | [1] | Continue the loop condition expression}}
 
{{TableRowPropertie2| Test | [[Boolean]] | [[Term]] | - | [1] | Continue the loop condition expression}}
 
|}
 
|}
 +
 +
== OTL Examples ==
 +
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 +
public procedure main()
 +
{
 +
  Integer Integer1;
 +
 +
  while (Integer1 < 10) : WhileLoop1
 +
  {
 +
      Integer1 = (Integer1 + 1);
 +
  }
 +
 +
  do
 +
  {
 +
      Integer1 = (Integer1 + 1);
 +
  } while (Integer1 < 10) : WhileLoop2
 +
}
 +
</syntaxhighlight>
  
 
== See also ==
 
== See also ==
 
[[ForLoop]] <br/>
 
[[ForLoop]] <br/>
 
[[ForeachLoop]]
 
[[ForeachLoop]]

Revision as of 10:09, 2 February 2015

Classification

Name WhileLoop
Short Description Loop that is iterated until the condition evaluates to false.
Class Action
Extension OTX Core library
Group Core related actions
Exceptions -
Checker Rules -
Standard Compliant Yes

OTL Syntax

// While (do)
while (BooleanTerm) : WhileLoopName
{
   ...
}

//Do while
do
{
   ...
} while (BooleanTerm) : WhileLoopName

Description

The OTX (do) WhileLoop activity contains a sequence of activities that are executed repeatedly until the condition evaluates to false. The expression for the condition is either before (while) or calculated according to (do while) the loop and tested.

Icons Note.png Please keep in mind that Do While at least once iterate loop!

The loop can be exited about the activities of break, return, or throw. The continue activity stops the current iteration and continues with the next iteration, without having to leave the loop.

Properties

Name Data Type Class Default Cardinality Description
IsPostTested Boolean Value - [0..1] The condition is tested before the execution of the loop (while false) or afterwards (true, do-while)
Test Boolean Term - [1] Continue the loop condition expression

OTL Examples

public procedure main()
{
   Integer Integer1;

   while (Integer1 < 10) : WhileLoop1
   {
      Integer1 = (Integer1 + 1);
   }

   do
   {
      Integer1 = (Integer1 + 1);
   } while (Integer1 < 10) : WhileLoop2
}

See also

ForLoop
ForeachLoop