Code vs. Strings: Difference between revisions
Lou Montana (talk | contribs) m (Add Columns template usage) |
Lou Montana (talk | contribs) m (Text replacement - "<tt>([a-zA-Z0-9\. _"\\']+)<\/tt>" to "{{hl|$1}}") |
||
Line 5: | Line 5: | ||
Using | Using | ||
* double quotes: | * double quotes: {{hl|"Hello"}} | ||
or | or | ||
* curled braces <tt>{a=a+1}</tt> | * curled braces <tt>{a=a+1}</tt> |
Revision as of 23:56, 15 November 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.
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 data type Code: Last updated: 2.02
- &&
- ||
- addPublicVariableEventHandler
- and
- apply
- call
- catch
- collect3DENHistory
- count
- default
- deleteAt
- do
- else
- exitWith
- findIf
- forEachMemberAgent
- forEachMemberTeam
- forEachMember
- forEach
- for
- get
- if
- in
- isFinal
- isNil
- onCommandModeChanged
- onEachFrame
- onGroupIconClick
- onGroupIconOverEnter
- onGroupIconOverLeave
- onHCGroupSelectionChanged
- onMapSingleClick
- onPlayerConnected
- onPlayerDisconnected
- onPreloadFinished
- onPreloadStarted
- onTeamSwitch
- or
- select
- spawn
- switch
- then
- toString
- try
- waitUntil
- while
- with
String Commands
Commands passed as data type String:
- map onDoubleClick "Code"
- map onMapSingleClick "Code"