<p class="TextInTable">If the variables are separated with comma (e.g. DIM sPar1, sPar2, sPar3 AS STRING), only Variant variables will be defined up to the last variable. An own definition line should be used for each variable.</p>
<p class="TextInTable">Dim is used to declare local variables within Subs. Global variables outside of Subs are declared with the PUBLIC or PRIVATE statements.</p>
<p class="Paragraph">VarName: Any variable or array name.</p>
<p class="Paragraph">Start, End: Numerical values or constants ranging from -32768 to 32767 which define the number of elements (NumberElements=(end-start)+1) and the index range.</p>
<p class="Paragraph">Start and End can be numerical expressions, if ReDim is applied at the procedure level.</p>
<p class="Paragraph">VarType: Key word used to declare the data type of a variable.</p>
<p class="Paragraph">Long: Long integer variable (-2.147.483.648 - 2.147.483.647)</p>
<p class="Paragraph">Object: Object variable (Note: can only be subsequently defined with Set!)</p>
<p class="Paragraph">Single: Single-precision floating-point variable (3,402823 x 10E38 - 1,401298 x 10E-45).</p>
<p class="Paragraph">String: String variable consisting of a maximum of 64,000 ASCII characters.</p>
<p class="Paragraph">[Variant] : Variant variable type (contains all types, specified by definition). If no key word is given, variables are automatically defined as Variant Type , unless a statement from DefBool to DefVar was used.</p>
<p class="Paragraph">In OpenOffice.org Basic, variables need not to be declared explicitly. Only arrays must declared before use. A variable can be declared with the Dim statement, using commas to separate multiple declarations. To declare a variable type, enter a type-declaration character following the name or use a corresponding key word.</p>
<p class="Paragraph">OpenOffice.org Basic supports single or multi-dimensional arrays, defined by a specified variable type. Arrays are suitable if the program contains lists or tables to be edited. The advantage of arrays is that it is possible to address individual elements according to indexes, which can be formulated as numeric expressions or variables.</p>
<p class="Paragraph">Arrays are declared with the Dim statement. There are two methods to define the index range:</p>
<p class="Paragraph">DIM text(20) as String REM 21 elements numbered from 0 to 20</p>
<p class="Paragraph">DIM text(5 to 25) as String REM 21 elements numbered from 5 to 25</p>
<p class="Paragraph">DIM text(-15 to 5) as String REM 21 elements (including 0)</p>
<p class="Paragraph">REM numbered from -15 to 5</p>
<p class="Paragraph">Two-dimensional data field</p>
<p class="Paragraph">DIM text(20,2) as String REM 63 elements; form 0 to 20 level 1, from 0 to 20 level 2 and from 0 to 20 level 3.</p>
<p class="Paragraph">All array types can be declared dynamic if the ReDim statement is used within the procedure (in Subs or functions) to define the number of dimensions. Generally, array dimensions can only be defined once, and cannot be subsequently modified. Within a procedure, an array can be declared with <span class="T1">ReDim</span>; dimensions can only be defined by numeric expressions, ensuring that the fields are only as large as necessary.</p>