| **Navigation:**  [[introduction.htm|Language Reference]] > 3 - Variable Declarations > Data Declarations and Memory Allocation >====== Variable Size Declarations ====== | [[data declaration sections.htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[new allocate heap memory .htm|{{btn_next_n.gif|Next page}}]] | | || It is now possible to declare variables of STRING-like and DECIMAL/PDECIMAL types of variable size to the compiler. Restrictions are the same as for variable-size arrays (see below): declarations are available in the procedure or routine local scope only, and all variables used in the expression must be known at the time of the variable's creation. Example: **  PROGRAM** ** ** **  MAP** **  TestProc(LONG)** **  END** ** ** **  CODE** **  TestProc(200) !can also be an initialized variable** ** ** **TestProc    PROCEDURE(LONG VarLength)** ** ** **VarString   STRING(VarLength)** ** ** **  CODE** **  VarString = 'String of up to 200 characters'** ** ** __**Variable-size arrays**__ Consider the following example: **VariableArray  ROUTINE** **  DATA** **Element     LONG(100)                 !assign number of elements** **DynArray    CSTRING(100),DIM(Element) !declare a variable length array** **  CODE** **  !process DynArray** There are 3 restrictions when using this technique: 1) The dimensioned variable (//Element//) must be locally declared in the respective PROCEDURE or ROUTINE data section and have no STATIC, THREAD or EXTERNAL attributes applied. 2) The dimensioned variable can not be a field component of any compound structure (GROUP,QUEUE, CLASS, RECORD) 3) All variables used in dimension expressions must be initialized at the moment of array initialization, i.e., they must be declared with an initial value before the array declaration, or they must be declared in outer scope and receive a value before the call to the PROCEDURE or ROUTINE, or they can be a parameter of the PROCEDURE.