Arrays
An array of variables can be defined using the syntax '<data type> <variable name> [ <expression> ]'. Any of the types in the Data Types list can be used. For example:
int myArray[15];
Note that unlike ANSI C, the size of the array can be any expression including variables, functions, or operators. For example
int myArray[ FileSize() - myInt * 0x10 + (17 << 5) ];
The individual elements of the array can be accessed using the '[ ]' operator. For example:
for( i = 0; i < 15; i++ )
myArray[i] = i;
If an array is declared with size zero a warning will be printed out and no variable will be created, but no error will be generated.
Strings
An array of characters is treated as a special string type. The keyword 'string' can also be used to declare a string. The operators '=', '+=', and comparison operators can be used on strings as if they were a separate data type. For example:
char str[15] = "First";
string s = "Second";
string r1 = str + s;
string r2 = str;
r2 += s;
return (r1 == r2);
Strings will automatically resize if assigned too many characters, and a warning will be displayed in the Output text area. All strings are assumed to be null-terminated. For a list of functions that can be used when working with strings, see String Functions.
|