|   |   | 
| (9 intermediate revisions by 3 users not shown) | 
| Line 1: | Line 1: | 
|  | {{SideTOC}}
 |  | #REDIRECT [[:Category: Data 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.
 |  | 
|  |   |  | 
|  |   |  | 
|  | == Definition ==
 |  | 
|  |   |  | 
|  | The data type of a variable depends on the value given to it on [[Variables#Initialization|initialization]].
 |  | 
|  |  myVar = ""; {{cc|myVar is now a [[String]]}}
 |  | 
|  |   |  | 
|  | a local variable should be prefixed with '''[[private]]''' ({{arma3}}) or '''[[local]]''' ({{arma2}}) to avoid a potential upper-[[Variables#Scopes|scope]] variable overwrite:
 |  | 
|  |  [[private]] _myLocalVariable = "";	{{cc|{{arma3}}}}
 |  | 
|  |  [[local]] _myLocalVariable = "";	{{cc|{{arma2}}}}
 |  | 
|  |   |  | 
|  |   |  | 
|  | == 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 = "";	{{cc|myVar is a [[String]]}}
 |  | 
|  |  myVar = 0;	{{cc|myVar is now a [[Number]]}}
 |  | 
|  |   |  | 
|  |   |  | 
|  | == Available Types ==
 |  | 
|  |   |  | 
|  | {| class="wikitable sortable"
 |  | 
|  | ! Type !! {{Name|ofp|short}} !! {{Name|arma|short}} !! {{arma2}} !! {{arma3}}
 |  | 
|  | |-
 |  | 
|  | | [[Array]]		|| {{task/}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Boolean]]		|| {{task/}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Group]]		|| {{task/}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Number]]		|| {{task/}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Object]]		|| {{task/}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Side]]		|| {{task/}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[String]]		|| {{task/}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |- <!-- ArmA -->
 |  | 
|  | | [[Code]]		|| {{task}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Config]]		|| {{task}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Control]]		|| {{task}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Display]]		|| {{task}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Location]]		|| {{task}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Script (Handle)]]	|| {{task}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Structured Text]]	|| {{task}} || {{task/}} || {{task/}} || {{task/}}
 |  | 
|  | |- <!-- Arma 2 -->
 |  | 
|  | | [[Diary Record]]	|| {{task}} || {{task}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Task]]		|| {{task}} || {{task}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Team Member]]	|| {{task}} || {{task}} || {{task/}} || {{task/}}
 |  | 
|  | |-
 |  | 
|  | | [[Namespace]]		|| {{task}} || {{task}} || {{task/}} || {{task/}}
 |  | 
|  | |}
 |  | 
|  |   |  | 
|  |   |  | 
|  | == Magic Types ==
 |  | 
|  |   |  | 
|  | There are some magic data types, which are not really datatypes, as they do not describe any particular value.
 |  | 
|  |   |  | 
|  | * [[Any Value]]
 |  | 
|  | * [[Anything]]
 |  | 
|  | * [[Nothing]]
 |  | 
|  | * [[Void]]
 |  | 
|  |   |  | 
|  |   |  | 
|  | == Syntactical Helper Types ==
 |  | 
|  |   |  | 
|  | Some more types are used to provide for a construction of syntactically richer constructs than normal unary / binary operators.
 |  | 
|  |   |  | 
|  | * [[If Type]]
 |  | 
|  | * [[While Type]]
 |  | 
|  | * [[Switch Type]]
 |  | 
|  | * [[For Type]]
 |  | 
|  |   |  | 
|  |   |  | 
|  | [[Category: Data Types]]
 |  |