{"name":"Code vs. Strings","title":"Code vs. Strings","type":"topic","url":"https://community.bistudio.com/wiki/Code_vs._Strings","revid":378168,"updated":"2026-03-02T16:50:28Z","aliases":["Code Commands","Code strings"],"markdown":"Since Armed Assault the convention to use quotation marks for Strings and curly braces for Code has been formalised.\nSome \"exceptions\" exist, for example with onMapSingleClick and onDoubleClick that take String as Code.\nWhen scripting, `'abc'` or `\"abc\"` generally indicates a String data type, and brackets `{ }` indicate Code data type.\n\nIn Operation Flashpoint, many language constructs (including forEach) use the concept of \"code strings\".\nCode is passed as a string to them and they interpret it as code if they wish.\nSince Operation Flashpoint v1.85, Code is also accepted.\n\n```sqf\n// Operation Flashpoint / Armed Assault only!\n\"_x setDammage 1\" forEach _units;\n\n// from Operation Flashpoint v1.85+ up to Arma 3\n{ _x setDamage 1 } forEach _units;\n```\n\n### Code to String / String to Code\n\n```sqf\n_code = { hint \"Hello there (code)\"; };\n_string = \"hint 'Hello there (string)';\";\n\n_stringCode = compile _string;    // from string to code (Armed Assault v1.00)\n_codeString = toString _code;    // from code to string (Arma 3 v2.02)\n```\n\n### Code Commands\n\n**Code commands** are any commands from the scripting language expecting a coded statement string as one of their parameters.\nEarlier engines accepted code as such when it was provided as a String using quotation marks, *or* using braces.\nSince Armed Assault the engine **specifically** requires braces.\nThus, because the way the engine determines whether it is dealing with code has changed, this list is presented here.\n\nCommands passed as Code data type: (as of Arma 3 v2.02)\n\n- &&\n- ||\n- addPublicVariableEventHandler\n- and\n- apply\n- call\n- catch\n- collect3DENHistory\n- count\n- default\n- deleteAt\n- do\n- else\n- exitWith\n- findIf\n- forEachMemberAgent\n- forEachMemberTeam\n- forEachMember\n- forEach\n- for\n- get\n- if\n- in\n- isFinal\n- isNil\n- onCommandModeChanged\n- onEachFrame\n- onGroupIconClick\n- onGroupIconOverEnter\n- onGroupIconOverLeave\n- onHCGroupSelectionChanged\n- onMapSingleClick\n- onPlayerConnected\n- onPlayerDisconnected\n- onPreloadFinished\n- onPreloadStarted\n- onTeamSwitch\n- or\n- select\n- spawn\n- switch\n- then\n- toString\n- try\n- waitUntil\n- while\n- with\n\n### String Commands\n\nCommands passed as String data type:\n\n- map onDoubleClick \"Code\"\n- map onMapSingleClick \"Code\"","sections":[{"heading":null,"level":1,"markdown":"Since Armed Assault the convention to use quotation marks for Strings and curly braces for Code has been formalised.\nSome \"exceptions\" exist, for example with onMapSingleClick and onDoubleClick that take String as Code.\nWhen scripting, `'abc'` or `\"abc\"` generally indicates a String data type, and brackets `{ }` indicate Code data type.\n\nIn Operation Flashpoint, many language constructs (including forEach) use the concept of \"code strings\".\nCode is passed as a string to them and they interpret it as code if they wish.\nSince Operation Flashpoint v1.85, Code is also accepted.\n\n```sqf\n// Operation Flashpoint / Armed Assault only!\n\"_x setDammage 1\" forEach _units;\n\n// from Operation Flashpoint v1.85+ up to Arma 3\n{ _x setDamage 1 } forEach _units;\n```"},{"heading":"Code to String / String to Code","level":3,"markdown":"```sqf\n_code = { hint \"Hello there (code)\"; };\n_string = \"hint 'Hello there (string)';\";\n\n_stringCode = compile _string;    // from string to code (Armed Assault v1.00)\n_codeString = toString _code;    // from code to string (Arma 3 v2.02)\n```"},{"heading":"Code Commands","level":3,"markdown":"**Code commands** are any commands from the scripting language expecting a coded statement string as one of their parameters.\nEarlier engines accepted code as such when it was provided as a String using quotation marks, *or* using braces.\nSince Armed Assault the engine **specifically** requires braces.\nThus, because the way the engine determines whether it is dealing with code has changed, this list is presented here.\n\nCommands passed as Code data type: (as of Arma 3 v2.02)\n\n- &&\n- ||\n- addPublicVariableEventHandler\n- and\n- apply\n- call\n- catch\n- collect3DENHistory\n- count\n- default\n- deleteAt\n- do\n- else\n- exitWith\n- findIf\n- forEachMemberAgent\n- forEachMemberTeam\n- forEachMember\n- forEach\n- for\n- get\n- if\n- in\n- isFinal\n- isNil\n- onCommandModeChanged\n- onEachFrame\n- onGroupIconClick\n- onGroupIconOverEnter\n- onGroupIconOverLeave\n- onHCGroupSelectionChanged\n- onMapSingleClick\n- onPlayerConnected\n- onPlayerDisconnected\n- onPreloadFinished\n- onPreloadStarted\n- onTeamSwitch\n- or\n- select\n- spawn\n- switch\n- then\n- toString\n- try\n- waitUntil\n- while\n- with"},{"heading":"String Commands","level":3,"markdown":"Commands passed as String data type:\n\n- map onDoubleClick \"Code\"\n- map onMapSingleClick \"Code\""}],"categories":["Scripting Topics"],"groups":["Scripting"]}