{"name":"do","title":"do","type":"command","url":"https://community.bistudio.com/wiki/do","revid":311159,"updated":"2022-05-11T13:17:42Z","groups":["Program Flow"],"status":"ok","games":{"ofp":"1.85","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.85","arma3_since":"0.50","description":"Executes *code*. Used as part of a construct, such as while, with, for and switch. The *code* is always executed in missionNamespace unless do is used with with as an argument.","syntaxes":[{"syntax":"construct do code","params":[{"name":"construct","type":"While Type (while), With Type (with), For Type (for), Switch Type (switch)","type_expr":"While Type | With Type | For Type | Switch Type"},{"name":"code","type":"Code","type_expr":"Code"}],"returns":{"type":"Anything","type_expr":"Anything"},"form":"binary","left":{"text":"construct"},"right":{"text":"code"}}],"examples":[{"text":"```sqf\nwhile { b > a } do\n{\n    a = a + 1;\n};\n```","code":["while { b > a } do\n{\n\ta = a + 1;\n};"]},{"text":"```sqf\nwith uiNamespace do\n{\n    MyUIVar = MyUIVar + 5;\n};\n```","code":["with uiNamespace do\n{\n\tMyUIVar = MyUIVar + 5;\n};"]},{"text":"```sqf\nfor \"_i\" from 1 to 10 do\n{\n    systemChat str _i;\n    sleep 0.5;\n};\n```","code":["for \"_i\" from 1 to 10 do\n{\n\tsystemChat str _i;\n\tsleep 0.5;\n};"]},{"text":"```sqf\nswitch (50) do\n{\n    case 25: { hint \"25\" };\n    case 50: { hint \"50\" }; // hints \"50\"\n    case 75: { hint \"75\" };\n    default { hint \"nope\" };\n};\n```","code":["switch (50) do\n{\n\tcase 25: { hint \"25\" };\n\tcase 50: { hint \"50\" }; // hints \"50\"\n\tcase 75: { hint \"75\" };\n\tdefault { hint \"nope\" };\n};"]}],"see_also":["Control Structures"]}