Data Types: Difference between revisions
Jump to navigation
Jump to search
m (Text replacement - "{{Checkbox|yes}}" to "{{Icon|checked}}") |
m (merge request) |
||
Line 1: | Line 1: | ||
{{TOC|side}} | {{TOC|side}} | ||
The '''data type''' of a [[Variables|variable]] specifies which data it may contain. Certain [[Operators|operators]] and [[:Category:Scripting Commands|scripting commands]] require variables to be of certain types. | The '''data type''' of a [[Variables|variable]] specifies which data it may contain. Certain [[Operators|operators]] and [[:Category:Scripting Commands|scripting commands]] require variables to be of certain types. | ||
{{Wiki|merge|:Category: Data Types}} | |||
== Definition == | == Definition == |
Revision as of 13:48, 10 February 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 | ||||
Boolean | ||||
Group | ||||
Number | ||||
Object | ||||
Side | ||||
String | ||||
Code | ||||
Config | ||||
Control | ||||
Display | ||||
Location | ||||
Script (Handle) | ||||
Structured Text | ||||
Diary Record | ||||
Task | ||||
Team Member | ||||
Namespace | ||||
HashMap | ||||
HashMapKey |
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.