Data Types: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "Armed Assault 2" to "{{arma2}}") |
Lou Montana (talk | contribs) (Change variable types presentation and fix ArmA 2 → Arma 2 link) |
||
Line 1: | Line 1: | ||
The '''data type''' of a [[Variables| | {{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}}}} | |||
== 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]]}} | |||
== Available Types == | == 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 == | == 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 22: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
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.