Data Types: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "Armed Assault 2" to "{{arma2}}")
(Change variable types presentation and fix ArmA 2 → Arma 2 link)
Line 1: Line 1:
The '''data type''' of a [[Variables|variables]] specifies which data it may contain. Certain [[Operators|operators]] and [[:Category:Scripting Commands|scripting commands]] require variables to be of certain types.
{{SideTOC}}
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 ==
== Definition ==


The data type of a variable depends on the value given to it on [[Variables#Initialization|initialization]].
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}}}}


myVar = "";
=> myVar is now a [[String]]


== Redefinition ==
== Redefinition ==


The data type of a variable may be changed at any point of the game by just redefining the variable with another type.  
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]]}}


myVar = "";
myVar = 0;
=> myVar is now a [[Number]]


== Available Types ==
== Available Types ==


These are the available data types in [[Operation Flashpoint]]:
{| class="wikitable sortable"
 
! Type !! {{Name|ofp|short}} !! {{Name|arma|short}} !! {{arma2}} !! {{arma3}}
* [[Array]]
|-
* [[Boolean]]
| [[Array]] || {{task/}} || {{task/}} || {{task/}} || {{task/}}
* [[Group]]
|-
* [[Number]]
| [[Boolean]] || {{task/}} || {{task/}} || {{task/}} || {{task/}}
* [[Object]]
|-
* [[Side]]
| [[Group]] || {{task/}} || {{task/}} || {{task/}} || {{task/}}
* [[String]]
|-
 
| [[Number]] || {{task/}} || {{task/}} || {{task/}} || {{task/}}
In [[Armed Assault]], the following data types have been added:
|-
 
| [[Object]] || {{task/}} || {{task/}} || {{task/}} || {{task/}}
* [[Code]]
|-
* [[Config]]
| [[Side]] || {{task/}} || {{task/}} || {{task/}} || {{task/}}
* [[Control]]
|-
* [[Display]]
| [[String]] || {{task/}} || {{task/}} || {{task/}} || {{task/}}
* [[Script (Handle)]]
|- <!-- ArmA -->
* [[Structured Text]]
| [[Code]] || {{task}} || {{task/}} || {{task/}} || {{task/}}
 
|-
In [[ArmA_2|{{arma2}}]], the following data types have been added:
| [[Config]] || {{task}} || {{task/}} || {{task/}} || {{task/}}
* [[Diary_Record]]
|-
* [[Task]]
| [[Control]] || {{task}} || {{task/}} || {{task/}} || {{task/}}
* [[Team_Member]]
|-
* [[Namespace]]
| [[Display]] || {{task}} || {{task/}} || {{task/}} || {{task/}}
 
|-
In [[VBS2]], the following data type has been added:
| [[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/}}
|}


* [[Editor Object]]


== Magic Types ==
== Magic Types ==
Line 58: Line 71:
* [[Nothing]]
* [[Nothing]]
* [[Void]]
* [[Void]]


== Syntactical Helper Types ==
== Syntactical Helper Types ==
Line 69: Line 83:




[[Category: Data Types| ]]
[[Category: Data Types]]

Revision as of 23:20, 24 February 2020

Template:SideTOC 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:task/ Template:task/ Template:task/ Template:task/
Boolean Template:task/ Template:task/ Template:task/ Template:task/
Group Template:task/ Template:task/ Template:task/ Template:task/
Number Template:task/ Template:task/ Template:task/ Template:task/
Object Template:task/ Template:task/ Template:task/ Template:task/
Side Template:task/ Template:task/ Template:task/ Template:task/
String Template:task/ Template:task/ Template:task/ Template:task/
Code Template:task Template:task/ Template:task/ Template:task/
Config Template:task Template:task/ Template:task/ Template:task/
Control Template:task Template:task/ Template:task/ Template:task/
Display Template:task Template:task/ Template:task/ Template:task/
Location Template:task Template:task/ Template:task/ Template:task/
Script (Handle) Template:task Template:task/ Template:task/ Template:task/
Structured Text Template:task Template:task/ Template:task/ Template:task/
Diary Record Template:task Template:task Template:task/ Template:task/
Task Template:task Template:task Template:task/ Template:task/
Team Member Template:task Template:task Template:task/ Template:task/
Namespace Template:task Template:task Template:task/ Template:task/


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.