•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The GFA-Basic Compendium
Author      : GFA Systemtechnik GmbH
Version     : GFABasic.HYP v2.98 (12/31/2023)
Subject     : Documentation/Programming
Nodes       : 899
Index Size  : 28056
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Document not found
@help       : Help
@options    : +g -i -s +z
@width      : 75
@hostname   : STRNGSRV
@hostname   : CAB     
@hostname   : HIGHWIRE
@hostname   : THING   
View Ref-FileOPTION BASE n

n: iexp (must be 0 or 1)

With the help of the command OPTION BASE it can be decided whether an array is
to contain a zeroth element or not. With OPTION BASE 0 (default) a zeroth
element is allocated, with OPTION BASE 1 it is not, and the array starts with
element number 1.

The contents of fields are not changed by the OPTION BASE instruction, however
the indices may be, as in the following:

Example:

    DIM x%(3)
    FOR i%=3 DOWNTO 0
      x%(i%)=i%
      PRINT i%,x%(i%)
    NEXT i%
    '
    OPTION BASE 1
    FOR i%=3 DOWNTO 0
      PRINT i%,x%(i%)
    NEXT i%

--> x%() is declared, by default including the zeroth element, and the
    elements are given the values 0-3 and printed. After OPTION BASE 1, there
    is no longer a zeroth element, and accessing the element 3 actually
    accesses what was element 2, etc.

The program ends with an error message on attempting to access the no longer
valid zeroth element of the array.

Memo: OPTION BASE 1 causes problems with compiled programs. The library
      contains a serious bug which renders OPTION BASE 1 unreliable. Stick to
      OPTION BASE 0 and everything is fine.