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-FileVariable Types
3 allows the following variable types:
Type Postfix Memory requirements Range
Boolean ! 1 byte (1 bit in arrays) 0 or -1 (FALSE or TRUE)
Byte | 1 byte 0 to 255
Word & 2 bytes -32768 to 32767
Long % 4 bytes -2147483648 to 2147483647
Float # 8 bytes 2.225073858507E-308 to 3.595386269725E+1000
String $ 0 to 32767 bytes ASCII value 0 to 255 for each character
Boolean (logical) variables can accept only the values 0 (FALSE) or -1
(TRUE). If a non-zero value is assigned, then this value is taken as -1. This
variable type is designated by the postfix '!', and occupies '1' byte of
memory. In boolean arrays elements require only one bit.
Example:
b!=TRUE
c!=x>y
Byte variables can accept values between 0 and 255. Larger values will
provoke a "Number not byte" error. The postfix for this variable type is the
vertical rule character '|'. As the name implies, this variable type occupies
one byte.
Example:
x|=128
Word variables are signed 2-byte integers. The postfix of this type is
'&'. Numbers in the range from -32768 to 32767 can be represented. Outside
this range, a "Number not word" error occurs.
Example:
x&=32767
Long variables are signed 4-byte integers with the postfix '%'. Numbers
can be represented in the range from -2147483648 to 2147483647.
Example:
x%=2000000000
Float variables are signed 8-byte floating point with the postfix '#'. The
range of representable numbers extends from 2.225073858507E-308 to
3.595386269725E+1000. As this is the default type, no postfix is necessary. The
numerical accuracy is approximately 14 decimal places.
Example:
x=123456789e123
String variables are designated by the postfix '$'. They can have a
maximum length of 32767 characters. Strings are administered by means of a
so-called descriptor, six bytes in length. The first 4 bytes contain the
address of the character string, the last 2 bytes contain the length of the
string. If a string contains and odd number of characters a zero filler byte is
added. The address of the descriptor (Backtrailer) is also added.
Example:
a$="qwertyuiop"
The address of all variable types can be determined with the help of the
functions VARPTR() (V:) and ARRPTR() (*).
Memo: For more information on the internal storage of floats see page
'GFA-Basic v3 float format'.
There seems to be a difference between floats used in the Editor versus
compiled. For example:
f=2.5E+310
PRINT f
PRINT STR$(f)
The Editor produces the expected result "2.5E+310" while the
compiled version produces a different result "2.499999997857E+310".
The book ' Programmer's Reference Guide Volume I' (page 8)
states a variable name can be up to 255 characters long.
The v2.x manual (page 47) states this about variable names:
Names of variables must begin with a letter and can be any length
(limited, of course by the length of a line). After the first letter in
the name, digits, underscore, and period are allowed. The full name is
always used to distinguish between variables.
Function names appear to follow the same rules as variable names.
Label names however do not follow the same rules. See GOTO for details.
Procedure names appear to follow the same rules as labels.
Notes on boolean!() arrays:
These are not stored in the logical order as one might assume.
Example:
DIM b!(8)
ARRAYFILL b!(),FALSE
b!(0)=TRUE
PRINT BIN$(BYTE{V:b!(0)},8) !results -> "00000001"
ARRAYFILL b!(),FALSE
b!(7)=TRUE
PRINT BIN$(BYTE{V:b!(0)},8) !results -> "10000000"
For speed reasons GFA stores them backwards. Thus accessing a boolean!()
is not particularly useful unless this is the behaviour you expect.
A signed byte is considered to be in the range of -128 to 127.
The Motorola 68K series of processors use the big-endian format.
Exponent range wrongly documented as -/+308, it's actually -/+1000.
Display bugs with an exponent of 1000: a=2.5E+1000 -> a=2.5E+:00