{"name":"break","operator":null,"title":"break","type":"command","url":"https://community.bistudio.com/wiki/break","revid":370194,"updated":"2024-11-06T11:55:55Z","groups":["Program Flow"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"2.02"}],"since":{"game":"arma3","name":"Arma 3","version":"2.02"},"arma3_since":"2.02","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Skips all loop iterations (for, forEach, while, findIf etc).","syntaxes":[{"syntax":"break","since":null,"effect":null,"exec":null,"params":[],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"nullary","operator":null,"left":null,"right":null}],"examples":[{"text":"```sqf\n// prints 0, 1 and then exits\nfor \"_i\" from 0 to 3 do\n{\n    if (_i == 2) then { break };\n    systemChat str _i;\n};\n```","code":["// prints 0, 1 and then exits\nfor \"_i\" from 0 to 3 do\n{\n\tif (_i == 2) then { break };\n\tsystemChat str _i;\n};"]},{"text":"```sqf\nprivate _moneyHolder = objNull;\n{\n    if (\"Money_roll\" in items _x) then\n    {\n        _moneyHolder = _x;\n        break;\n    };\n} forEach units group player;\n\nif (isNull _moneyHolder) then\n{\n    hint \"We have to find this money.\";\n}\nelse\n{\n    hint format [\"%1 has the money!\", name _moneyHolder];\n};\n```","code":["private _moneyHolder = objNull;\n{\n\tif (\"Money_roll\" in items _x) then\n\t{\n\t\t_moneyHolder = _x;\n\t\tbreak;\n\t};\n} forEach units group player;\n\nif (isNull _moneyHolder) then\n{\n\thint \"We have to find this money.\";\n}\nelse\n{\n\thint format [\"%1 has the money!\", name _moneyHolder];\n};"]},{"text":"```sqf\n0 spawn\n{\n    private _value = 0;\n\n    while { _value < 10 } do\n    {\n        if (_value == 8) then\n        {\n            break; // 8 and 9 will never be printed\n        };\n\n        systemChat str _value ;\n        _value = _value + 1;\n    };\n};\n```","code":["0 spawn\n{\n\tprivate _value = 0;\n\n\twhile { _value < 10 } do\n\t{\n\t\tif (_value == 8) then\n\t\t{\n\t\t\tbreak; // 8 and 9 will never be printed\n\t\t};\n\n\t\tsystemChat str _value ;\n\t\t_value = _value + 1;\n\t};\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["continueWith","continue","breakWith","breakOut"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Program Flow","Introduced with Arma 3 version 2.02","Scripting Commands"]}