breakOut: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<code>([^<]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^<]*) *<\/code>" to "<code>$1$2$3</code>") |
Lou Montana (talk | contribs) m (Text replacement - "<sqf>([^↵][^<]*↵[^<]*)<\/sqf>" to "<sqf> $1 </sqf>") |
||
(21 intermediate revisions by the same user not shown) | |||
Line 19: | Line 19: | ||
|descr= Breaks out of the [[Variables#Scopes|scope]] with given '''name'''. | |descr= Breaks out of the [[Variables#Scopes|scope]] with given '''name'''. | ||
* An unknown [[scopeName]] name will cause the script error {{ | * An unknown [[scopeName]] name will cause the script error {{hl|Generic error in expression}} | ||
* If multiple scopes with the same '''name''' exist, the command will break out the nearest scope. See | * If multiple scopes with the same '''name''' exist, the command will break out the nearest scope. See {{Link|#Example 3}}. | ||
|s1= [[breakOut]] name | |s1= [[breakOut]] name | ||
|p1= name: [[String]] - | |p1= name: [[String]] - name of the scope which was previously set with [[scopeName]]. <sqf inline>""</sqf> will exit the current scope (see also [[exitWith]]) | ||
|r1= [[Nothing]] | |r1= [[Nothing]] | ||
Line 32: | Line 32: | ||
|s2since= arma3 1.48 | |s2since= arma3 1.48 | ||
|p21= value: [[Anything]] - | |p21= value: [[Anything]] - a value to return | ||
|p22= name: [[String]] - | |p22= name: [[String]] - name of the scope which was previously set with [[scopeName]]. <sqf inline>""</sqf> will exit the current scope (see also [[exitWith]]) | ||
|r2= [[Anything]] - | |r2= [[Anything]] - will return '''value''' | ||
|x1= < | |x1= <sqf> | ||
scopeName "main"; | |||
while { true } do { | |||
scopeName "loop1"; | |||
while {true} do { | |||
scopeName "loop2"; | |||
if (condition1) then {breakTo "main"}; // Breaks all scopes and return to "main" | |||
if (condition2) then {breakOut "loop2"}; // Breaks scope named "loop2" | |||
sleep 1; | |||
}; | }; | ||
sleep 1; | |||
};</ | }; | ||
</sqf> | |||
|x2= < | |x2= <sqf> | ||
call { | |||
scopeName "main"; | |||
123 | call { | ||
123 breakOut "main" | |||
}; | }; | ||
345 | 345 | ||
}; // call returns 123</ | }; // call returns 123 | ||
</sqf> | |||
|x3= < | |x3= <sqf> | ||
call { | |||
scopeName "Main"; // Parent Main | |||
call { | |||
"String" | scopeName "Main"; // Child Main | ||
"String" breakOut "Main"; // Will break out of child main and return "String" to parent main | |||
}; | }; | ||
};</ | }; | ||
</sqf> | |||
|seealso= [[scopeName]] [[breakTo]] [[exitWith]] | |seealso= [[scopeName]] [[breakTo]] [[exitWith]] | ||
}} | }} |
Latest revision as of 19:42, 3 September 2024
Description
- Description:
- Breaks out of the scope with given name.
- Groups:
- Program Flow
Syntax
- Syntax:
- breakOut name
- Parameters:
- name: String - name of the scope which was previously set with scopeName. "" will exit the current scope (see also exitWith)
- Return Value:
- Nothing
Alternative Syntax
- Syntax:
- value breakOut name
- Parameters:
- value: Anything - a value to return
- name: String - name of the scope which was previously set with scopeName. "" will exit the current scope (see also exitWith)
- Return Value:
- Anything - will return value
Examples
- Example 1:
- Example 2:
- Example 3:
Additional Information
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
Categories:
- Scripting Commands
- Introduced with Armed Assault version 1.00
- ArmA: Armed Assault: New Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: Program Flow