User Tools

Site Tools


arma2:scripting:common_scripting_errors

ArmA 2 Common Scripting Errors

Error Generic Error in Expression

This error occurs when the type of data an operator is expecting does not match.

Example:

_myString = "The meaning of life is " + 42

Error Invalid Number in Expression

This usually occurs when an expression is left incomplete or malformed.

Example:

_myNumber = 2 + 3 +

Error Type Something Expected Nothing

This error usually occurs when a statement is incomplete, malformed, or non-existent.

Examples:

non-existent statement:

7 + 6 * 5

malformed statement:

3 = 4

incomplete statement:

_myVariable

Error Type String Expected Code

This error occurs when there is a syntax error contained inside a block of code that makes up part of another statement. The error will be identified as being part of the original statement, not on the specific line where it actually occurs. For instance, if there is a syntax error inside an if statement's “then” block or “else” block, the error will be identified in front of the “then” keyword or “else” keyword respectively.

Example:

if (_USD + _USDcent + _CAD + _CADcent + _ZWD == 0) then
{
	hint "Your wallet is empty.";
}
else
{
	_output = "Your wallet contains:";
	if (_USD+_USDcent > 0) then
	{
		_output = _output + format["\n- United States Dollars: %1.%2 USD", _USD, _USDcent];
	} <-- Missing semicolon
	if (_CAD+_CADcent > 0) then
	{
		_output = _output + format["\n- Canadian Dollars: %1.%2 CAD", _CAD, _CADcent];
	} <-- Missing semicolon
	if (_ZWD > 0) then
	{
		_output = _output + format["\n- Zimbabwean Dollars: %1 ZWD", _ZWD];
	} <-- Missing semicolon ...
	hint _output;
};

There are missing semicolons on each of the if statements within the else block, but the error will be identified as being before the “else” statement as “Type String, Expected Code”.

Error Unknown Operator

This error occurs when the game engine has attempted to parse something as an operator, but could not successfully find the given symbol.

Examples:

_myBits = 1002 | 43
_myVariable = "hello " concat "world!"

There are several reasons why this might happen. If a script intended for a new version of OFP makes use of a new operator, and is run on an old copy of the game, this error will show up. Another common cause is when executing a formatted String as an instruction, where a variable inside the instruction is undefined.

Example:

["a = %1", b]

Outputted instruction:

a = scalar bool array string 0xfcfffef

Result:

The engine interprets 'scalar' as an uninitialised variable (similar to 'b' in the above example), and the parser expects an operator as the next token. 'bool' cannot be found in the list of operators (since it isn't one), and so an Unknown Operator message is given.

Error Zero Divisor

This error occurs when the variable you are trying to divide has a value of zero, or when you attempt to divide a variable by 0. It also occurs when you attempt to access an element of an array which does not exist.

Example:

_myVar = 0 / 15
_myVar = 15 / 0
_myVar = [1,2,3] select 15

When an error makes no sense

Sometimes, the displayed error will not appear to be correct. The error parser will point you to a line of code which is correct, yet it will tell you that some strange error exists at that point.

In this case, the problem usually lies beneath that point in the code. Usually the source of the error is actually a missing parenthesis, bracket, curly brace, etc. Usually the error message says that it encountered a string where it expected code.

Example:

for "_i" from 0 to 1 do
{
	_str = format["mystring";
};

In this example, the error will be shown to originate just to the left of the word “do”. However, the error is actually caused by a line in the code beneath the do statement. (Such an error would be difficult to spot if it were many more lines down in the code.)

scalar bool array string 0xe0ffffef

If variables don't exist, their value as string is generally a “scalar bool array string 0xe0ffffef” error.

Examples:

hint format ["%1", undefined_variable]
 
hint (if (format ["%1", undefined_variable] == "scalar bool array string 0xe0ffffef") then [{"Variable undefined"},{"Variable already defined"}])
arma2/scripting/common_scripting_errors.txt · Last modified: 2011-07-24 08:57 (external edit)