Data Types: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "{{SideTOC}}" to "{{TOC|side}}")
(→‎Available Types: Added HashMap, HashMapKey)
Line 60: Line 60:
|-
|-
| [[Namespace]] || {{Checkbox|no}} || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}}
| [[Namespace]] || {{Checkbox|no}} || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[HashMap]] || {{Checkbox|no}} || {{Checkbox|no}} || {{Checkbox|no}} || {{Checkbox|yes}}
|-
| [[HashMapKey]] || {{Checkbox|no}} || {{Checkbox|no}} || {{Checkbox|no}} || {{Checkbox|yes}}
|}
|}


== Magic Types ==
== Magic Types ==

Revision as of 10:48, 25 January 2021

The data type of a variable specifies which data it may contain. Certain operators and scripting commands require variables to be of certain types.


Definition

The data type of a variable depends on the value given to it on initialization.

myVar = ""; // myVar is now a String

a local variable should be prefixed with private (Arma 3) or local (Arma 2) to avoid a potential upper-scope variable overwrite:

private _myLocalVariable = "";	// Arma 3
local _myLocalVariable = "";	// Arma 2


Redefinition

The data type of a variable may be changed at any point of the game by just redefining the variable with another type.

myVar = "";	// myVar is a String
myVar = 0;	// myVar is now a Number


Available Types

Type OFP ArmA Arma 2 Arma 3
Array Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Boolean Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Group Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Number Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Object Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Side Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
String Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Code Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Config Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Control Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Display Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Location Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Script (Handle) Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Structured Text Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Diary Record Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Task Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Team Member Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
Namespace Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
HashMap Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox
HashMapKey Template:Checkbox Template:Checkbox Template:Checkbox Template:Checkbox

Magic Types

There are some magic data types, which are not really datatypes, as they do not describe any particular value.


Syntactical Helper Types

Some more types are used to provide for a construction of syntactically richer constructs than normal unary / binary operators.