Variables must be declared before they are used. Unique names are used to identify variables. To declare a variable, you must specify its type and a unique name. Declaration of variable is not an operator.
Simple types are:
•char, short, int, long, uchar, ushort, uint, ulong integers;
•color integer representing the RGB-color;
•datetime the date and time, an unsigned integer containing the number of seconds since 0 hour January 1, 1970;
•bool boolean values true and false;
•double double-precision floating point number;
•float single-precision floating point number;
•string character strings.
Complex or compound types:
Structures are composite data types, constructed using other types.
You can't declare variables of the structure type until you declare the structure.
Array is the indexed sequence of identical-type data:
Only an integer can be an array index. No more than four-dimensional arrays are allowed. Numbering of array elements starts with 0. The last element of a one-dimensional array has the number which is 1 less than the array size. This means that call for the last element of an array consisting of 50 integers will appear as a. The same concerns multidimensional arrays: A dimension is indexed from 0 to the dimension size-1. The last element of a two-dimensional array from the example will appear as m.
Static arrays can't be represented as timeseries, i.e., the ArraySetAsSeries() function, which sets access to array elements from the end to beginning, can't be applied to them. If you want to provide access to an array the same as in timeseries, use the dynamic array object.
If there is an attempt to access out of the array range, the executing subsystem will generate a critical error and the program will be stopped.
Access specifiers define how the compiler can access variables, members of structures or classes.
The const specifier declares a variable as a constant, and does not allow to change this variable during runtime. A single initialization of a variable is allowed when declaring it. The const specifier can't be applied to members of structures and classes.
To access members of structures and classes use the following qualifiers:
•public allows unrestricted access to the variable or class method
•virtual applies only to class methods (but not to methods of structures) and tells the compiler that this method should be placed in the table of virtual functions of the class.
There are three storage classes: static, input and extern. These modifiers of a storage class explicitly indicate to the compiler that corresponding variables are distributed in a pre-allocated area of memory, which is called the global pool. Besides, these modifiers indicate the special processing of variable data. If a variable declared on a local level is not a static one, memory for such a variable is allocated automatically at a program stack. Freeing of memory allocated for a non-static array is also performed automatically when going beyond the visibility area of the block, in which the array is declared.