do: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category:Scripting Commands OFP 1.[4-9]{2}(\|(\{\{uc:\{\{PAGENAME\}\}\}\}|#))?\]\] " to "")
m (Some wiki formatting)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| ofpr
|game1= ofp
|version1= 1.85
 
|game2= ofpe
|version2= 1.00
 
|game3= arma1
|version3= 1.00
 
|game4= arma2
|version4= 1.00
 
|game5= arma2oa
|version5= 1.50
 
|game6= tkoh
|version6= 1.00
 
|game7= arma3
|version7= 0.50


|gr1= Program Flow
|gr1= Program Flow


|1.85
|descr= Executes ''code''. Used as part of a construct, such as [[while]], [[with]], [[for]] and [[switch]]. The ''code'' is always executed in [[missionNamespace]] unless [[do]] is used with [[with]] as an argument.
 
|s1= construct [[do]] code


| Executes ''code''. Used as part of a construct, such as [[while]], [[with]], [[for]] and [[switch]]. The ''code'' is always executed in [[missionNamespace]] unless [[do]] is used with [[with]] as an argument.
|p1= construct: [[While Type]] ([[while]]), [[With Type]] ([[with]]), [[For Type]] ([[for]]), [[Switch Type]] ([[switch]])


| construct [[do]] code
|p2= code: [[Code]]


|p1= construct: One of:
|r1= [[Anything]]
* [[While Type]] ([[while]])
* [[With Type]] ([[with]])
* [[For Type]] ([[for]])
* [[Switch Type]] ([[switch]])


|p2= code: [[Code]]
|x1= <sqf>
while { b > a } do
{
a = a + 1;
};
</sqf>


| [[Anything]]
|x2= <sqf>
with uiNamespace do
{
MyUIVar = MyUIVar + 5;
};
</sqf>


|x1= <code>[[while]] { b > a } [[do]] { a = a + 1 };</code>
|x3= <sqf>
for "_i" from 1 to 10 do
{
systemChat str _i;
sleep 0.5;
};
</sqf>


|x2= Repair all members of a group to such a level that they are able to stand up:
|x4= <sqf>
<code>{
switch (50) do
[[while]] {![[canStand]] [[Magic Variables|_x]] && [[alive]] [[Magic Variables|_x]]} [[do]] {
{
[[Magic Variables|_x]] [[setDamage]] ([[damage]] [[Magic Variables#x|_x]] - 0.01);
case 25: { hint "25" };
};
case 50: { hint "50" }; // hints "50"
} [[forEach]] [[units]] [[group]] unitname;</code>
case 75: { hint "75" };
default { hint "nope" };
};
</sqf>


|seealso= [[Control Structures]]
|seealso= [[Control Structures]]
}}
}}
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
{{GameCategory|arma1|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}

Latest revision as of 15:17, 11 May 2022

Hover & click on the images for description

Description

Description:
Executes code. Used as part of a construct, such as while, with, for and switch. The code is always executed in missionNamespace unless do is used with with as an argument.
Groups:
Program Flow

Syntax

Syntax:
construct do code
Parameters:
construct: While Type (while), With Type (with), For Type (for), Switch Type (switch)
code: Code
Return Value:
Anything

Examples

Example 1:
while { b > a } do { a = a + 1; };
Example 2:
with uiNamespace do { MyUIVar = MyUIVar + 5; };
Example 3:
for "_i" from 1 to 10 do { systemChat str _i; sleep 0.5; };
Example 4:
switch (50) do { case 25: { hint "25" }; case 50: { hint "50" }; // hints "50" case 75: { hint "75" }; default { hint "nope" }; };

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