{"name":"breakOut","operator":null,"title":"breakOut","type":"command","url":"https://community.bistudio.com/wiki/breakOut","revid":369282,"updated":"2024-09-03T18:42:47Z","groups":["Program Flow"],"status":"ok","replaced_by":[],"games":[{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma1","name":"Armed Assault","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Breaks out of the scope with given **name**.\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","since":null,"effect":null,"exec":null,"params":[{"name":"name","type":"String","optional":false,"default":null,"description":"name of the scope which was previously set with scopeName. `\"\"` will exit the current scope (see also exitWith)","types":["String"],"since":null,"text":"name: String - name of the scope which was previously set with scopeName. `\"\"` will exit the current scope (see also exitWith)"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"name","types":["String"]}},{"syntax":"value breakOut name","since":"arma3 1.48","effect":null,"exec":null,"params":[{"name":"value","type":"Anything","optional":false,"default":null,"description":"a value to return","types":["Anything"],"since":null,"text":"value: Anything - a value to return"},{"name":"name","type":"String","optional":false,"default":null,"description":"name of the scope which was previously set with scopeName. `\"\"` will exit the current scope (see also exitWith)","types":["String"],"since":null,"text":"name: String - name of the scope which was previously set with scopeName. `\"\"` will exit the current scope (see also exitWith)"}],"returns":{"type":"Anything","types":["Anything"],"description":"will return value","text":"Anything - will return **value**"},"form":"binary","operator":null,"left":{"text":"value","types":["Anything"]},"right":{"text":"name","types":["String"]}}],"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};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["scopeName","breakTo","exitWith"],"notes":[],"categories":["ArmA: Armed Assault: New Scripting Commands","ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Program Flow","Introduced with Armed Assault version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}