breakOut: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\{\{cc\|([^} ]*)\}\}" to "// $1")
m (Text replacement - "<code>([^<]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^<]*) *<\/code>" to "<code>$1$2$3</code>")
Line 38: Line 38:
|r2= [[Anything]] - Will return '''value'''
|r2= [[Anything]] - Will return '''value'''


|x1= <code>[[scopeName]] "main";
|x1= <code>scopeName "main";
[[while]] {[[true]]} [[do]] {
[[while]] {[[true]]} [[do]] {
[[scopeName]] "loop1";
[[scopeName]] "loop1";
Line 48: Line 48:
};
};
[[sleep]] 1;
[[sleep]] 1;
};
};</code>
</code>


|x2= <code>[[call]] {
|x2= <code>call {
[[scopeName]] "main";
[[scopeName]] "main";
[[call]] {
[[call]] {
Line 59: Line 58:
}; // call returns 123</code>
}; // call returns 123</code>


|x3= <code>[[call]] {
|x3= <code>call {
[[scopeName]] "Main"; // Parent Main
[[scopeName]] "Main"; // Parent Main
[[call]] {
[[call]] {
Line 65: Line 64:
"String" [[breakOut]] "Main"; // Will break out of child main and return "String" to parent main
"String" [[breakOut]] "Main"; // Will break out of child main and return "String" to parent main
};
};
};
};</code>
</code>


|seealso= [[scopeName]] [[breakTo]] [[exitWith]]
|seealso= [[scopeName]] [[breakTo]] [[exitWith]]
}}
}}

Revision as of 14:00, 12 May 2022

Hover & click on the images for description

Description

Description:
Breaks out of the scope with given name.
  • An unknown scopeName name will cause the script error Generic error in expression
  • If multiple scopes with the same name exist, the command will break out the nearest scope. See Example 3.
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.
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.
Return Value:
Anything - Will return value

Examples

Example 1:
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; };
Example 2:
call { scopeName "main"; call { 123 breakOut "main" }; 345 }; // call returns 123
Example 3:
call { scopeName "Main"; // Parent Main call { scopeName "Main"; // Child Main "String" breakOut "Main"; // Will break out of child main and return "String" to parent main }; };

Additional Information

See also:
scopeName breakTo exitWith

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