{"name":"breakOut","title":"breakOut","type":"command","url":"https://community.bistudio.com/wiki/breakOut","revid":369282,"updated":"2024-09-03T18:42:47Z","groups":["Program Flow"],"status":"ok","games":{"arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"arma1 1.00","arma3_since":"0.50","description":"Breaks out of the scope with given **name**.\n\n- An unknown scopeName name will cause the script error `Generic error in expression`\n- If multiple scopes with the same **name** exist, the command will break out the nearest scope. See Example 3.","syntaxes":[{"syntax":"breakOut name","params":[{"name":"name","type":"String","description":"name of the scope which was previously set with scopeName. `\"\"` will exit the current scope (see also exitWith)","type_expr":"String"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"unary","right":{"text":"name"}},{"syntax":"value breakOut name","since":"arma3 1.48","params":[{"name":"value","type":"Anything","description":"a value to return","type_expr":"Anything"},{"name":"name","type":"String","description":"name of the scope which was previously set with scopeName. `\"\"` will exit the current scope (see also exitWith)","type_expr":"String"}],"returns":{"type":"Anything","type_expr":"Anything","description":"will return value","text":"Anything - will return **value**"},"form":"binary","left":{"text":"value"},"right":{"text":"name"}}],"examples":[{"text":"```sqf\nscopeName \"main\";\nwhile { true } do {\n    scopeName \"loop1\";\n    while {true} do {\n        scopeName \"loop2\";\n        if (condition1) then {breakTo \"main\"}; // Breaks all scopes and return to \"main\"\n        if (condition2) then {breakOut \"loop2\"}; // Breaks scope named \"loop2\"\n        sleep 1;\n    };\n    sleep 1;\n};\n```","code":["scopeName \"main\";\nwhile { true } do {\n\tscopeName \"loop1\";\n\twhile {true} do {\n\t\tscopeName \"loop2\";\n\t\tif (condition1) then {breakTo \"main\"}; // Breaks all scopes and return to \"main\"\n\t\tif (condition2) then {breakOut \"loop2\"}; // Breaks scope named \"loop2\"\n\t\tsleep 1;\n\t};\n\tsleep 1;\n};"]},{"text":"```sqf\ncall {\n    scopeName \"main\";\n    call {\n        123 breakOut \"main\"\n    };\n    345\n}; // call returns 123\n```","code":["call {\n\tscopeName \"main\";\n\tcall {\n\t\t123 breakOut \"main\"\n\t};\n\t345\n}; // call returns 123"]},{"text":"```sqf\ncall {\n    scopeName \"Main\"; // Parent Main\n    call {\n        scopeName \"Main\"; // Child Main\n        \"String\" breakOut \"Main\"; // Will break out of child main and return \"String\" to parent main\n    };\n};\n```","code":["call {\n\tscopeName \"Main\"; // Parent Main\n\tcall {\n\t\tscopeName \"Main\"; // Child Main\n\t\t\"String\" breakOut \"Main\"; // Will break out of child main and return \"String\" to parent main\n\t};\n};"]}],"see_also":["scopeName","breakTo","exitWith"]}