Data Types

From Bohemia Interactive Community
Revision as of 01:00, 8 February 2021 by R3vo (talk | contribs) (Text replacement - "{{Checkbox|yes}}" to "{{Icon|checked}}")
Jump to navigation Jump to search

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 Checked Checked Checked Checked
Boolean Checked Checked Checked Checked
Group Checked Checked Checked Checked
Number Checked Checked Checked Checked
Object Checked Checked Checked Checked
Side Checked Checked Checked Checked
String Checked Checked Checked Checked
Code Unchecked Checked Checked Checked
Config Unchecked Checked Checked Checked
Control Unchecked Checked Checked Checked
Display Unchecked Checked Checked Checked
Location Unchecked Checked Checked Checked
Script (Handle) Unchecked Checked Checked Checked
Structured Text Unchecked Checked Checked Checked
Diary Record Unchecked Unchecked Checked Checked
Task Unchecked Unchecked Checked Checked
Team Member Unchecked Unchecked Checked Checked
Namespace Unchecked Unchecked Checked Checked
HashMap Unchecked Unchecked Unchecked Checked
HashMapKey Unchecked Unchecked Unchecked Checked

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.