OWBasic for Pocketviewer

Home INTRO Group VARIABLES Alphabetical Index

Constants and Initialized Arrays

CONST <identifier>= <constant>
CONST <identifier>=( <constant>, <constant> .. )

With CONST one can define integer constants and initialised arrays.

Integer constants are defined in the first form. After definition they can be used in the program.
Example:
CONST adim=65
DIM a[#adim], b[#adim]
FOR I=0 to #adim : ....
The usage of constant can help to understand a program, if the names are "speaking". If a constant needs a change, all relevant changes are done with one change in the source code. In the example a change of adim would change both array declarations and the loop.

At compile time a constant can be assigned a constant value:
#<constant>=<constant integer expression>

Initialized arrays can be defined with CONST in the second form. The datatype is determined by the usual conventions and can be INTEGER or FLOAT. The size of the array is determined by the size of the list of constants.
Initialized arrays can be used just like other arrays, but are initialised with the given values. Example:
CONST s$=("one", "two", "three") :! constant string array
CONST f#=(0.2,0.4,0.6) :! constant float array
CONST c&=("my char var") :! constant char array
CONST b!=(true,false,1,0,0,1) :! constant bool array
CONST i=(8,8,426,384,384,21888) : ! constant integer array
CONST &ps$=(&s) :! constant string pointer array
DRAWICON i,5,5


  • ARRAY - Array declarations
Home INTRO Group VARIABLES Alphabetical Index