for forspec: Difference between revisions
Jump to navigation
Jump to search
m (example) |
m (example) |
||
Line 16: | Line 16: | ||
|x1 = <code> '''for''' [{_x<nowiki>=</nowiki>1},{_x<<nowiki>=</nowiki>10},{_x<nowiki>=</nowiki>_x+1}] [[do]] {[[debugLog]] _x;} </code> | |x1 = <code> '''for''' [{_x<nowiki>=</nowiki>1},{_x<<nowiki>=</nowiki>10},{_x<nowiki>=</nowiki>_x+1}] [[do]] {[[debugLog]] _x;} </code> | ||
|x2 = <code> _a = 0; '''for''' [{},{_a <= 10},{_a = _a + 1}] [[do]] {[[debugLog]] _a;}; </code> | |x2 = <code> _a = 0; '''for''' [{},{_a <= 10},{_a = _a + 1}] [[do]] {[[debugLog]] _a;}; </code> | ||
|x3 = <code> '''for''' [{_a = 0; _b = 1},{_a <= 10},{_a = _a + 1; _b = _b + _b}] [[do]] {}; //_a = 11; _b = 2048;</code> | |||
| [[Control Structures]], [[for do]] |= See also | | [[Control Structures]], [[for do]] |= See also |
Revision as of 13:02, 29 June 2014
Description
- Description:
- Creates cycle, using C like style. See example.
- Groups:
- Uncategorised
Syntax
Examples
- Example 1:
for [{_x=1},{_x<=10},{_x=_x+1}] do {debugLog _x;}
- Example 2:
_a = 0; for [{},{_a <= 10},{_a = _a + 1}] do {debugLog _a;};
- Example 3:
for [{_a = 0; _b = 1},{_a <= 10},{_a = _a + 1; _b = _b + _b}] do {}; //_a = 11; _b = 2048;
Additional Information
- See also:
- Control Structuresfor do
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
- Posted on Apr 15, 2014 - 12:54
- ffur2007slx2_5
-
In ArmA3 ver 1.16 Please note the difference between for forspec and for do, for forspec detects Boolean in each scope while for do doesn’t. e.g.
command Structure Summary for forspec a= 0; b = true; for [{_i = 0},{_i < 10 && b},{_i = _i + 1}] do { a = a + 1; if (a >= 7) then {b = false} }
loop can be exited via Boolean control, possible workaround can be like BIS_fnc_areEqual for do a= 0; for "_i" from 0 to 10 do { a = a + 1; if (a >= 7) exitwith {} };
have to be exited via exitWith