Code vs. Strings: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Rewritten introduction to reflect exceptions)
No edit summary
Line 1: Line 1:
Since [[Armed Assault]] the convention to use quotation marks for [[String]]s and curly braces for [[Code]] has been formalised. Exceptions, however, do exist: for example [[bindKey (VBS2)]], [[onMapSingleClick]] and [[onDoubleClick]]. When scripting ''<nowiki>'...'</nowiki>'', ''"..."'' or ''""...""'' generally indicates data type String, and {...} indicates data type Code.
Since [[Armed Assault]] the convention to use quotation marks for [[String]]s and curly braces for [[Code]] has been formalised. Exceptions, however, do exist: for example [[bindKey (VBS2)]], [[onMapSingleClick]] and [[onDoubleClick]]. When scripting ''<nowiki>'...'</nowiki>'', ''"..."'' or ''""...""'' generally indicates data type String, and {...} indicates data type Code.


In [[Operation Flashpoint | OFP]] many language constructs (including [[forEach]], [[if]], [[while]]) use the concept of "code strings".<br>
In [[Operation Flashpoint | 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}).
Code is passed as a string to them and they interpret it as code if they wish.<br>
Since version 1.85, string constants can be written in two ways:
 
Using double quotes (like "Hello") or curled braces (like {a=a+1}).


A partial list of commands which expect code as parameter is provided at [[Code Commands]].
[[Category: Scripting_Topics ]]
[[Category: Scripting_Topics ]]

Revision as of 13:06, 18 January 2010

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}).

A partial list of commands which expect code as parameter is provided at Code Commands.