while: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (added see also, revert)
m (fixed formatting)
Line 17: Line 17:
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
||x1= <code>while {x<10} [[do]] {x<nowiki>=</nowiki>x+1} </code>|= Example 1
|x1= <code>while {x<10} [[do]] {x<nowiki>=</nowiki>x+1} </code>|= Example 1
 
|x2=A practical example: Repair all members of a group to such a level that they are able to stand up: <code><nowiki>{</nowiki><br>&nbsp;&nbsp;while <nowiki>{</nowiki>([[not]] [[canStand]] _x) [[and]] ([[alive]] _x)<nowiki>}</nowiki> [[do]] <nowiki>{</nowiki><br>&nbsp;&nbsp;&nbsp;&nbsp;_x [[setDammage]] ([[getDammage]] _x) - 0.01;<br>&nbsp;&nbsp;<nowiki>};</nowiki><br><nowiki>}</nowiki> [[forEach]] units [[group]] unitname; </code> |= Example 2____________________________________________________________


||x2=A more practical example: To repair all the members of a group to such a level that they are all able to stand up: <code><nowiki>{</nowiki>while <nowiki>{</nowiki>([[not]] [[canStand]] _x) [[and]] [[alive]] _x)<nowiki>}</nowiki> [[do]] <nowiki>{</nowiki>_x [[setDammage]] ([[getDammage]] _x) - 0.01<nowiki>}}</nowiki>[[forEach]] units
[[group]] unitname </code> |= Example 2
____________________________________________________________________________________________
| [[Control Structures]] |= See also
| [[Control Structures]] |= See also


Line 32: Line 31:
<!-- Note Section END -->
<!-- Note Section END -->
</dl>
</dl>


<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>

Revision as of 07:30, 17 January 2007

Hover & click on the images for description

Description

Description:
First part of while construct.
Groups:
Uncategorised

Syntax

Syntax:
while condition
Parameters:
condition: Code
Return Value:
While Type

Examples

Example 1:
while {x<10} do {x=x+1}
Example 2:
A practical example: Repair all members of a group to such a level that they are able to stand up: {
  while {(not canStand _x) and (alive _x)} do {
    _x setDammage (getDammage _x) - 0.01;
  };
} forEach units group unitname;

Additional Information

See also:
Control Structures

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes


Bottom Section