•  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-FileDIM, DIM?()
OPTION BASE
ARRAYFILL

All variable types can be used in arrays, or 'fields'. An array can be
dimensioned with DIM, or the size of an array can be determined with DIM?().

The management of arrays in memory is effected by means of Descriptors. A
descriptor is a structure six bytes in length, the first four bytes of which
contain the address of the array. The next two bytes specify the number of
dimensions. The array field itself begins with sets of four bytes, giving the
number of elements in each dimension (beginning with the last dimension)
followed by the actual contents of the dimensions. With string arrays, instead
of the contents, the descriptors of the character strings follow the four
number-of-elements bytes. For example, after

    DIM a%(2,3)

*a%() gives the address of the array descriptor. The number of dimensions of
the array is in the last two bytes of the descriptor, therefore

    PRINT DPEEK(*a%()+4)

returns the value 2.

The array itself begins with the number of elements in the second dimension,
where the zeroth element is taken into account (assuming OPTION BASE 0 is
valid), followed by the number of elements in the first dimension. Then

    PRINT LPEEK(V:a%(0,0)-8)

returns the value 4.

    PRINT LPEEK(V:a%(0,0)-4)

returns the value 3

Following this, the actual contents in the order:

a%(0,0), a%(1,0), a%(2,0), a%(0,1), a%(1,1), a%(2,1), etc.

Memo: For speed considerations when compiling one should read section
      'Array Index Checking'.

      The library contains minor bugs which cause incorrect error messages.
      Error messages that don't work correctly at DIM:
        #14 'array dimensioned twice'
        #17 'dim index too large'
        It will appear to issue random error messages.