Code vs. Strings: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (page overhaul)
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 {{arma1}} the convention to use quotation marks for [[String]]s and curly braces for [[Code]] has been formalised. Exceptions, however, do exist. For example [[onMapSingleClick]] and [[onDoubleClick]].<br>
When scripting <tt><nowiki>'abc'</nowiki></tt>, <tt><nowiki>"abc"</nowiki></tt> or <tt><nowiki>""abc""</nowiki></tt> generally indicates data type String, and <tt>{   }</tt> indicates data type Code.


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}).
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:  <tt>"Hello"</tt>
or  
* curled braces <tt>{a=a+1}</tt>


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

Revision as of 00:04, 6 January 2021

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 onMapSingleClick and onDoubleClick.
When scripting 'abc', "abc" or ""abc"" generally indicates data type String, and { } indicates data type Code.

In Operation Flashpoint 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: "Hello"

or

  • curled braces {a=a+1}

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