Void: Difference between revisions
(Void is correct for this description.) |
(Merged in Undefined Variable Types) |
||
Line 23: | Line 23: | ||
[[if]] (undefinedVar == undefinedVar) [[then]] ... | [[if]] (undefinedVar == undefinedVar) [[then]] ... | ||
In Operation Flashpoint, a Variable becomes '''undefined''' when it is assigned to an undefined value, or an expression which refers to an undefined value somewhere. | |||
==Names== | |||
The [[String]] representation of an undefined variable is one of the following: | |||
[[Anything]]: scalar bool array string 0xfcffffef<br> | |||
[[Nothing]]: scalar bool array string nothing 0xfcffffef<br> | |||
[[Number]]: scalar<br> | |||
[[Boolean]]: bool<br> | |||
[[Array]]: array<br> | |||
'''Caution: the string specification of the undefined variables is undocumented, and it is very likely to change in future version of the scripting language.''' | |||
The reliable way to check if the variable is undefined is that it silently fails any expression evaluations on it. | |||
'''Example''': | |||
defined=false;if var==var then {defined=true};if var!=var then {defined=true}; | |||
if !defined then {/*we know it is undefined here*/} | |||
==Type Inference== | |||
Suppose the variable '''a''' is undefined, and we set the variable '''b''' like so:<br> | |||
b = a + [] | |||
The inferred type of b is now array - since b was the product result of an array [[a plus b|add]] operation with a definite array ([]) and an unknown type (a) | |||
'''b''''s string representation will now be 'array', and b wil be considered an undefined array. | |||
[[Category: Data Types]] | |||
[[Category: Magic Types]] | [[Category: Magic Types]] |
Revision as of 10:09, 7 September 2007
A variable of type Void is an undefined variable. When converted to a string with str or format, this variable will always return scalar bool array string 0xe0ffffef (in Armed Assault) or scalar bool array string 0xfcffffef (in Operation Flashpoint).
Undefining Variables
You can use nil to undefine variables.
myVar = 1; ... myVar = nil; myVar => undefined
Comparisons
No comparison with variables of this type will work.
Example:
// error if (undefinedVar == ...) then ...
// error if (undefinedVar == undefinedVar) then ...
In Operation Flashpoint, a Variable becomes undefined when it is assigned to an undefined value, or an expression which refers to an undefined value somewhere.
Names
The String representation of an undefined variable is one of the following:
Anything: scalar bool array string 0xfcffffef
Nothing: scalar bool array string nothing 0xfcffffef
Number: scalar
Boolean: bool
Array: array
Caution: the string specification of the undefined variables is undocumented, and it is very likely to change in future version of the scripting language.
The reliable way to check if the variable is undefined is that it silently fails any expression evaluations on it.
Example:
defined=false;if var==var then {defined=true};if var!=var then {defined=true}; if !defined then {/*we know it is undefined here*/}
Type Inference
Suppose the variable a is undefined, and we set the variable b like so:
b = a + []
The inferred type of b is now array - since b was the product result of an array add operation with a definite array ([]) and an unknown type (a)
b's string representation will now be 'array', and b wil be considered an undefined array.