1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 13:50:36 +00:00
QB64-PE/internal/help/OPTION_BASE.txt

52 lines
1.5 KiB
Plaintext
Raw Normal View History

2019-04-15 01:15:33 +00:00
The [[OPTION BASE]] statement is used to set the default lower bound of arrays.
{{PageSyntax}}
2019-04-15 01:15:33 +00:00
: [[OPTION BASE]] {0|1}
{{PageDescription}}
* This statement affects array declarations where the lower bound of a dimension is not specified.
2019-04-15 01:15:33 +00:00
* When used, [[OPTION BASE]] must come before any array declarations ([[DIM]]) to be affected.
* By default, the lower bound for arrays is zero, and may be changed to one using the statement.
* Otherwise, arrays will be dimensioned from element 0 if you DIM just the upper bounds.
2019-04-15 01:15:33 +00:00
* You can also set other array boundaries by using [[TO]] in the DIM declaration such as {{InlineCode}}DIM array(5 TO 10){{InlineCodeEnd}}
2019-04-15 01:15:33 +00:00
{{PageExamples}}
''Example 1:'' Set the default lower bound for array declarations to one.
{{CodeStart}}
{{Cl|OPTION BASE}} 1
' Declare a 5-element one-dimensional array with element indexes of one through five.
{{Cl|DIM}} array(5) {{Cl|AS}} {{Cl|INTEGER}}
{{Cl|PRINT}} {{Cl|LBOUND}}(array)
{{CodeEnd}}
{{OutputStart}} 1{{OutputEnd}}
''Example 2:'' Set the default lower bound for array declarations to zero.
{{CodeStart}} '' ''
{{Cl|OPTION BASE}} 0
' Declare an 18-element two-dimensional array with element indexes of zero through two
' for the first dimension, and 10 through 15 for the second dimension.
{{Cl|DIM}} array(2, 10 to 15) {{Cl|AS}} {{Cl|INTEGER}}
{{Cl|PRINT}} {{Cl|LBOUND}}(array, 1)
{{Cl|PRINT}} {{Cl|LBOUND}}(array, 2)
{{CodeEnd}}
{{OutputStart}} 0
10
{{OutputEnd}}
{{PageSeeAlso}}
2019-04-15 01:15:33 +00:00
* [[Arrays]], [[LBOUND]], [[UBOUND]]
* [[DIM]], [[REDIM]], [[STATIC]], [[COMMON]]
2019-04-15 01:15:33 +00:00
{{PageNavigation}}
<