Code vs. Strings

From Bohemia Interactive Community

Since Armed Assault the convention to use quotation marks for Strings and curly braces for Code has been formalised. Some "exceptions" exist, for example with onMapSingleClick and onDoubleClick that take String as Code.
When scripting, 'abc' or "abc" generally indicates a String data type, and brackets { } indicate Code data type.

In Operation Flashpoint, many language constructs (including forEach) use the concept of "code strings". Code is passed as a string to them and they interpret it as code if they wish.
Since Logo A0.png 1.85, Code is also accepted.

// Operation Flashpoint / Armed Assault only! "_x setDammage 1" forEach _units; // from Operation Flashpoint v1.85+ up to Arma 3 { _x setDamage 1 } forEach _units;


Code to String / String to Code

_code = { hint "Hello there (code)"; }; _string = "hint 'Hello there (string)';"; _stringCode = compile _string; // from string to code (Armed Assault v1.00) _codeString = toString _code; // from code to string (Arma 3 v2.02)


Code Commands

Code commands are any commands from the scripting language expecting a coded statement string as one of their parameters. Earlier engines accepted code as such when it was provided as a String using quotation marks, or using braces. Since Armed Assault the engine specifically requires braces. Thus, because the way the engine determines whether it is dealing with code has changed, this list is presented here.

Commands passed as Code data type: (as of Arma 3 logo black.png 2.02)


String Commands

Commands passed as String data type: