Data Types: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "{{task}}" to "{{Checkbox|no}}")
m (Text replacement - "^#redirect \[\[" to "#REDIRECT [[")
 
(7 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]] || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Boolean]] || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Group]] || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Number]] || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Object]] || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Side]] || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[String]] || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|- <!-- ArmA -->
| [[Code]] || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Config]] || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Control]] || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Display]] || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Location]] || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Script (Handle)]] || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Structured Text]] || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|- <!-- Arma 2 -->
| [[Diary Record]] || {{Checkbox|no}} || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Task]] || {{Checkbox|no}} || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Team Member]] || {{Checkbox|no}} || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|-
| [[Namespace]] || {{Checkbox|no}} || {{Checkbox|no}} || {{Checkbox|yes}} || {{Checkbox|yes}}
|}
 
 
== 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]]

Latest revision as of 23:03, 24 June 2022