Code vs. Strings

From Bohemia Interactive Community
Revision as of 12:48, 18 January 2010 by Besselinksjm (talk | contribs) (Rewritten introduction to reflect exceptions)
Jump to navigation Jump to search

Since Armed Assault the convention to use quotation marks for Strings and curly braces for Code has been formalised. Exceptions, however, do exist: for example bindKey (VBS2), onMapSingleClick and onDoubleClick. When scripting '...', "..." or ""..."" generally indicates data type String, and {...} indicates data type Code.

In OFP many language constructs (including forEach, if, while) use the concept of "code strings".
Code is passed as a string to them and they interpret it as code if they wish.
Since version 1.85, string constants can be written in two ways:

Using double quotes (like "Hello") or curled braces (like {a=a+1}).