for: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(_x is a magic variable... _i seams better)
(for is an independent operator)
Line 1: Line 1:
'''for''' can refer to these scripting commands:
{{Command|= Comments
*[[for forspec]]
____________________________________________________________________________________________
'''Example'''
for [{_i=1},{_i<=10},{_i=_i+1}] do {};
*[[for var]] 
'''Example'''
for "_i" from 1 to 10 do {};


| arma |= Game name


==See Also==
|1.00|= Game version
____________________________________________________________________________________________


[[Control Structures]]
| This operator creates a [[For Type]] which is used in the for-constructs (There is the [[for forspec]] and the [[for var]] syntax available for this construct) |= Description
____________________________________________________________________________________________


{{Disambig}}
| '''for''' arg |= Syntax
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
|p1= arg: [[String]] or [[Array]] - When using String it declares the index variable name like "_myVar" and when using Array it must be a 3-dimensional Array of [[Code]]|= Parameter 1
 
| [[For Type]] |= Return value
____________________________________________________________________________________________
 
|x1= <code>[[for]] "_i" [[from]] 1 [[to]] 10 [[do]] {[[debugLog]] _i;};</code> |= Example 1
|x2= <code>[[for]] "_i" [[from]] 9 [[to]] 1 [[step]] -2 [[do]] {[[debugLog]] _i;};</code> |= Example 2
|x3= <code> [[for]] [{_i=0}, {_i < 10}, {_i = _i + 1}] [[do]] {hint str _i};</code> |=Example 3
____________________________________________________________________________________________
 
| [[for forspec|for [ ]]], [[for_do|for do]], [[Control Structures]] |= See also
 
}}
 
<h3 style="display:none">Notes</h3>
<dl class="command_description">

Revision as of 13:37, 3 January 2017

-wrong parameter ("Arma") defined!-1.00
Hover & click on the images for description

Description

Description:
This operator creates a For Type which is used in the for-constructs (There is the for forspec and the for var syntax available for this construct)
Groups:
Uncategorised

Syntax

Syntax:
for arg
Parameters:
arg: String or Array - When using String it declares the index variable name like "_myVar" and when using Array it must be a 3-dimensional Array of Code
Return Value:
For Type

Examples

Example 1:
for "_i" from 1 to 10 do {debugLog _i;};
Example 2:
for "_i" from 9 to 1 step -2 do {debugLog _i;};
Example 3:
for [{_i=0}, {_i < 10}, {_i = _i + 1}] do {hint str _i};

Additional Information

See also:
for [ ]for doControl 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