Skip to main content
? Knighthawks

GFA BASIC 3.0 By Stefan Posthuma

There  are  some things in this world that should not  have  been 
invented.  Among these things are: the Bomb, Apartheid, Politics, 
and...  the concrete drill of my neighbour.  Right now,  while my 
trembling fingers are typing this, he is using it. He is using it 
in  such  a way that extremely powerful vibrations  are  created. 
These vibrations manifest themselves through my  senses,  tearing 
my  brains apart,  completely ruining the perfect biorythms  that 
made  me  happy  and driving me completely off  the  wall.  I  am 
seriously considering stopping now and parking my hard disk  head 
before  my hard disk is spontaneously erased.  Sometimes  I  have 
dark thoughts about entering the house next door with a  chainsaw 
and  do  some  things the guy in 'The  Texas  Chainsaw  Massacre' 
(great film. Just make sure your stomach is empty so its contents 
don't  end up all over the floor) never thought possible  with  a 
chainsaw. I will quit now because I can't hear myself think...

08:45 am
He is at it again.  I woke up,  my dreams being shattered by  the 
Noise.  Is this a sweet revenge for all the heavy music I  poured 
on him all these years?  But two seconds of this Evil Drilling is 
enough  to cover all records the Beasty Boys,  Public  Enemy,  LL 
Cool J,  and all other cutcreators ever made.  In fact, right now 
the Beasties are doing their best to counter the Noise, my stereo 
is vibrating so heavy that my mouse starts moving  spontaneously. 
If there is a Hell, it will sound like this down there..... 
Maybe he is trying to drill a hole in the wall and achieve a  new 
way of inter-neighbour communication.  But the first thing I will 
do  when I see his rotten face is throw a couple of  handgrenades 
through the hole and watch him explode....
Allright.  Sorry  for  these dark thoughts.  I will  pull  myself 
together and get down to business.

Silence at last. But I will take my revenge. I have ordered today 
a Stereo that will put all other Stereos to the shame. Check this 
out:  2 * 85 Watt Amplifier with connections for every electronic 
device you can think of.  Fully programmable CD-player with CCRS. 
Double casette deck with Dolby C and B,  fully separate  cassette 
unit,  CCRS  which will record a CD by just 1 push of  a  button, 
auto  reverse  on both decks,  synchronized recording  and  DPSS. 
Tuner with 20 preset stations and timer. Fully programmabe record 
player  with tangential arm.  Together with two 120  Watt  Magnat 
loudspeakers  and a remote control,  this Kenwood equipment  will 
blow my mind (and that of my parents,  my neighbour and all other 
living  things in the direct vincinity of my house).  It will  be 
delivered on Saturday and I can't wait!

Sometimes  I  tend  to overdo the 'human  interest'  part  of  my 
articles.  But I live under extreme conditions now.  My neighbour 
is torturing me and I can't see Evelien for two weeks because she 
has to study. (Sigh)

GFA 3.0 By Stefan Posthuma (a new beginning)

Frank Ostrowski really did it this time.

The  first thing that will strike you about GfA 3.0 is the  speed 
of the editor.  I think it is about twice as fast as the old  one 
and  it  works splendid.  There is a great feature  to  'fold'  a 
procedure.   Just  position  the  cursor  anywhere  in  the  line 
containing the procedure declaration and press Help.  The  entire 
procedure will be 'folded' and only the procedurename preceded by 
a '>' sign will remain. This greatly increases the readability of 
a program.  When I develop a program,  all procedures are folded, 
and the one I work on is open. Great.

The  little numeric keypad can also be used.  Using  Control  and 
these  keys  will make the keypad operate just like  the  keypads 
found on so many PCs. You can also press Control-( to permanently 
enable the keypad.  (Sort of a NUMLOCK key). There are a lot more 
Control-commands  which are shorthands for the many  function-key 
menus.  One  of these is very useful,  Control-U.  This one  will 
restore  the last line erased at the position of the  cursor.  So 
copying  a line is merely a question of  pressing  Control-Delete 
and Control-U. Move the cursor and each time you press Control-U, 
the line will appear. Very nice.

You  can also define marks in your source.  Just  press  Control-
number key,  and a (invisible) mark is placed.  Press  Alt-number 
key and the cursor will jump to the corresponding mark.

There is also a possibility to call a GEM-menubar so you can  use 
accessories  and  the lot.  The menu commands have  remained  the 
same,  only  the printer command has been enhanced.  You can  add 
special  commands to your listing which will influence  printing. 
Now you can do things such as number pages and print headers  and 
footers.  Also, the find command allows you to edit the last find 
string used.
A line number and a clock are added to the menu. You can edit the 
line number to jump to a certain line.
You  can also define groups of variables to have a certain  type. 
With the DEFxxx commands, you can e.g. specify that all variables 
starting with int_ are integers,  and all variables starting with 
f_ are floats. The Deflist command now has four options. 
All in all,  the editor has been improved.  Especially the faster 
operation and the procedure folding are very nice.

But there is more, much, much more.

I am now browing through the extensive manual, and I will mention 
all new things as I stumble along them.

VARIABLES

New variable types. Together with the old ones, there are now 6 
types of variables:

Name      Postfix        Memory used              Range

Boolean   !              1 Byte, in arrays 1 Bit  -1 or 0
Byte      |              1 Byte                   0 to 255
Word      &              2 Bytes                  -32768 to 32768
Integer   %              4 Bytes                  huge -+(2^32)/2 
Float     #              8 Bytes                  even bigger     
String    $              depends   

The commands STR$,  BIN$,  OCT$ and HEX$ can be given  optional 
parameters to specify the lenght of the string to be created.

There  is a command CINT which will produce a  rounded  integer 
from a float.

POINTERS

A host of pointer operators have been added.  This is how  they 
operate:
PRINT BYTE{x}  same as PRINT PEEK(x) (only faster)
BYTE{x} = 2    same as POKE x,2
These are the operators:
BYTE{},   CARD{},  INT{},  LONG{},  FLOAT{},  SINGLE{},  DOUBLE{} 
and CHAR{}
The CHAR{} operator is very useful as it reads and writes strings 
terminated   by  a  null-byte.   This  great  for  GEM  and   TOS 
communication. I have really been waiting for this one.

Also the command VAR will literally pass a variable to a routine. 
The  Varptr  command can be abbriveated to V:  and  the  ABSOLUTE 
command assigns an adress to a variable.

ARRAYS

To sort arrays,  use the QSORT and SSORT commands.  Very  quick 
and efficient. Also possible to co-sort other arrays. If you have 
two arrays, one containing the adress and the other one the name. 
You can sort the adress array and see to it that the elements  of 
the name array are also swapped to keep things allright.

The  INSERT and DELETE commands insert and delete array  elements 
and scroll all other elements up or down.  Together with the sort 
commands,  it  should be possible to write a simple  memory-based 
database in no-time.

MEMORY

The  INLINE  command is superb.  INLINE will reserve  a  part  of 
memory  inside  the source,  and will return the adress  of  this 
part. Pressing Help will present you with a menu which allows you 
to load,  save,  clear or dump the memory part.  Now you can load 
pieces of data (machine code or other stuff) into your source. If 
you  save the program and load it later on,  the inline  part  of 
memory will still be filled. Great!!!

Also  the  GEMDOS  commands  MALLOC,  MFREE,  MSHRINK  have  been 
implemented as real GfA commands.

ARITHMETRIC

There  are  two new functions called SINQ  and  COSQ.  These  are 
the same as SIN and COS,  only much faster (approx.  factor  10). 
But  they are less accurate,  still accurate enough  for  screen-
drawing. 

RANDOM

The  IBM-basic like RANDOMIZE command has been added.  This  will 
seed  the random-number generator with a certain value.  Is  this 
value  the  same,  the same sequence of random  numbers  will  be 
generated. This is great to produce test data which has to be the 
same every time you run the program.

INTEGER ARITHMETIC

The good old SUB,  MUL,  DIV,  DEC, INC and ADD are expanded with 
the following commands:

PRED(i) gives i-1 (but leaves i unaffected)
SUCC(i) gives i+1

a=ADD(5,x) is the same as a=5+x only faster:

ADD(), SUB(), MUL(), DIV() and MOD()

BIT OPERATIONS

The SUB,  ADD,  MUL and DIV instructions are assembler  mnemonics 
really. But there is some more assembler stuff added:

BCLR, BSET, BTST, BCHG, SHL, SHR, ROL, ROR.

The  shift  instructions can be succeded by a  size-specifier  to 
indicate the scope of the shift (8, 16 or 32 bit-shift)
The AND(),  XOR(),  IMP() and EQV() functions operate the same as 
the ADD(), SUB() etc. functions mentioned above.
The  SWAP() function swaps the two words in a  long.  The  BYTE() 
function  returns  the lower 8 bits and  the  CARD()  instruction 
returns the lower 16 bits, and the WORD() function sign-extends a 
16-bit integer to a 32-bit integer.

STRING FUNCTIONS

PRED() and SUCC() return the first character of the string.  So B 
becomes A or C. The ascii value is in- or decreased.
TRIM$  removes  leading  and trailing spaces  from  a  string.  I 
discovered  a  bug here,  trimming an empty string (or  a  string 
containing spaces only) will result in a '2 bombs, bus error'

RINSTR is the same as the old INSTR,  but searched backwards from 
the end of the string. Great to separate pathnames and filenames.

KEYBOARD INPUT AND SCREEN OUTPUT

The  MODE command will determine the format of the decimal  point 
and comma and the date format.
HTAB, VTAB and POS can position the cursor on the screen.

For keyboard input, there are a lot of KEYxxx functions added:

KEYPAD  allows you to enable or disable the numerical keypad  and 
the function key definitions.
KEYLOOK  reads a key from the keyboard buffer without  destroying 
it. 
KEYGET is the same as INP(2)
KEYTEST is the same as INKEY$
KEYPRESS simlulates the pressing of a certain key.
KEYDEF  allows you to program the function keys.  They also  work 
within the GfA editor.

FILE HANDLING

FGETDTA,  FSETDTA,  FSFIRST  and FSNEXT easyfy (is this  English? 
sounds  great  though) the use of the GEMDOS functions  with  the 
same name.

TOUCH updates the date and time of a file. (UNIX command)

PRINT # USING is now possible.  WRITE # writes strings  separated 
by semi-colons to a file.

STORE and RECALL are used to dump and read entrire  string-arrays 
to a file.

The  FIELD command can now handle integers and the  specification 
can be split across multipe lines.

SERIAL AND MIDI PORT

The commands INPAUX$ and IMPMID$ read strings from the serial and 
midi port.

MOUSE AND JOYSTICK

With  the  command SETMOUSE,  you can position the mouse  at  any 
coordinate on the screen.  The commands STICK and STRIG allow you 
to read the joysticks.

PROGRAM STRUCTURE

There  are  many significant improvements made  here.  Listen  to 
this:

If  you  want  to nest a couple of if-statements  which  are  all 
related, you can use ELSEIF now. So a structure like:

IF n$="Stefan" THEN
   PRINT "That's me!"
ELSE
   IF n$="Richard" THEN
      PRINT "He is our Master Correspondent!"
   ELSE
      PRINT "Don't know that dude."
   ENDIF
ENDIF

Will become:

IF n$="Stefan" THEN
   PRINT "That's me!"
ELSEIF n$="Richard" THEN
   PRINT "He is our Master Correspondent!"
ELSE
   PRINT "Don't know that dude."
ENDIF

This  will  avoid  the deep nesting of  IF  statements  and  will 
greatly improve the readability of your source.

C programmers will love the next one:

SELECT x
CASE 1
   PRINT "x equals 1!"
CASE 2 TO 4
   PRINT "x ranges from 2 to 4!"
CASE 5,6
   PRINT "x is 5 or 6"
DEFAULT
   PRINT "you fooled me!"
ENDSELECT

The  example explains the power of this wonderful  statement.  If 
you  substitute the numbers for 1-character  strings,  the  ASCII 
value of these strings is used.
You can jump out of this construction using CONT.

The loops have been enhanced with the following commands:

DO WHILE
DO UNTIL
LOOP WHILE
LOOP UNTIL

These  suckers,  together  with  the normal DO and  LOOP  can  be 
combined to create loops which will answer your every programming 
need.

One  of  the biggest improvements of GfA 3.0 is  the  ability  to 
create  your  own functions which behave  like  procedures.  This 
enables you to convert C-programs to GfA without much trouble. It 
also   allows  you  to  program  complex  algorithms   concerning 
recursive  calls.  A  classic example is  the  recursive  faculty 
calculation algorithm:

PRINT "The faculty of 10 = ";@faculty(10)
'
FUNCTION faculty(x%)
   IF x%=1 THEN
     RETURN 1
   ELSE
     RETURN x%*@faculty(x%-1)
   ENDIF
ENDFUNC

A function can be a complete program,  just like a procedure. The 
only difference is that you can return values. Unfortunately, you 
cannot 'fold' functions.

INTERRUPT PROGRAMMING

Yes folks, it is now possible to program interrupts in GfA BASIC. 
An  interrupt  is  a little (or sometimes big)  routine  that  is 
called  every x seconds (x is mostly smaller than 1),  no  matter 
what is happening. In GfA, interrupts are handled very graciously 
by the following commands:

EVERY ticks GOSUB proc
EVERY STOP
EVERY CONT

A tick is 1/200th of a second,  and ticks must be a multitude  of 
4. So if you program this:

EVERY 100 GOSUB whatever

The routine whatever is called twice a second.
It is also possible to call a routine after a certain  time.  The 
command 

AFTER ticks GOSUB proc

will see to this.    

PROGRAM DEBUGGING

The command 

TRON proc

will cause the routine proc to be called before processing a  new 
line of GfA.  The variable TRACE$ will now contain the line to be 
processed. This enables you to write inter-active debuggers.

The  DUMP command will dump variable names and their contents  or 
the  procedure and function names or all labels on the screen  or 
to a file.

GRAPHICS

The BOUNDARY command will enable or disable the boundary around a 
filled box, ellipse, circle or polyline.

The  CLIP  command has many variations and is used  to  define  a 
clipping area. All graphic output that falls outside the clipping 
retangle  will not be displayed.  Also,  the CLIP OFFSET  command 
determines the position of the (0,0) coordinate on the screen.

The DRAW command has been dramatically enhanced to support  LOGO-
like vector graphic commands like FORWARD,  LEFT TURN, PEN UP and 
the likes.

The POLYxxx commands can be given an offset.

LINE-A CALLS

The  following  routines use the very fast LINE-A  routines  that 
emulate  a blitter and are called by every GEM routine that  uses 
graphic output:

ACLIP sets the clipping retangle.
PSET plots a pixel with a certain color
PTST tests a pixel
ALINE draws a straight line
HLINE draws a horizontal line (very fast)
ARECT draws a filled retangle
APOLY draws a polyline
BITBLT copies retangular bit-map patterns
ACHAR prints a single character
ATEXT prints a string
L~A returns the adress of the LINE-A variables

VDI-CALLS

VDISYS calls a VDI routine
WORK_OUT returns values used in the OPEN WORKSTATION call
GDOS? returns TRUE or FALSE depending on an activated GDOS.
V~H returns the internal VDI handle used by GfA
V_OPNWK opens a workstation
V_CLSWK closes a workstation
V_OPNVWK opens a virtual workstation
V_CLSVWK closes a virtual workstation
V_CLRWK clears a workstation
V_UPDWK updates a workstation
VST_LOAD_FONTS loads the in ASSIGN.SYS indicated fonts
VST_UNLOAD_FONTS clears the memory used by the loaded fonts
VQ_EXTEND gives the coordinates of a retangle that can enclose  a 
certain text string.
VQT_NAME gives the name of a loaded font

PROCEDURE CALLS

The  new  RCALL function fills the register with values  from  an 
array  and calls an assembler routine.  After execution  of  this 
routine,  the  registers  will  be  copied  to  the  array  after 
execution. Really nice!

GEM INTERFACE

There  are  so many new GEM-related commands that it  would  take 
this  entire issue of ST NEWS to describe them al.  I  will  list 
them though:

OPENW (enhanced in GfA 3.0),  CLOSEW,  W_HAND,  W_INDEX,  CLEARW, 
TITLE,  INFOW, TOPW, FULLW, WINTAB, RC_INTERSECT, RC_COPY, ALERT, 
FILESELECT  (the good  old  one..),  OB_NEXT,  OB_HEAD,  OB_TAIL, 
OB_TYPE,  OB_FLAGS,  OB_STATE,  OB_SPEC,  OB_X, OB_Y, OB_W, OB_H, 
APPL_INIT,    APPL_READ,   APPL_WRITE,   APPL_FIND,   APPL_TPLAY, 
APPL_EXIT,   EVNT_KEYBD,   EVNT_BUTTON,  EVNT_MOUSE,  EVNT_MESAG, 
EVNT_TIMER,   EVNT_MULTI,   EVNT_DCLICK,  MENU_BAR,  MENU_ICHECK, 
MENU_TNORMAL,  MENU_TEXT,  MENU_REGISTER,  OBJC_ADD, OBJC_DELETE, 
OBJC_DRAW,   OBJC_FIND,   OBJC_OFFSET,   OBJC_ORDER,   OBJC_EDIT, 
OBJC_CHANGE,    FORM_DO,   FORM_DIAL,   FORM_ALERT,   FORM_ERROR, 
FORM_CENTER,     FORM_KEYBD,     FORM_BUTTON,     GRAF_RUBBERBOX, 
GRAF_DRAGBOX,    GRAF_MOVEBOX,    GRAF_GROWBOX,   GRAF_SHRINKBOX, 
GRAF_WATCHBOX,     GRAF_SLIDEBOX,     GRAF_HANDLE,    GRAF_MOUSE, 
GRAF_MKSTATE,  SCRP_READ,  SCRP_WRITE,  FSEL_INPUT,  WIND_CREATE, 
WIND_OPEN,    WIND_CLOSE,    WIND_DELETE,   WIND_GET,   WIND_SET, 
WIND_FIND,    WIND_UPDATE,   WIND_CALC,   RSRC_LOAD,   RSRC_FREE, 
RSRC_GADDR,   RSRC_SADDR,   RSRC_OBFIX,   SHEL_READ,  SHEL_WRITE, 
SHEL_GET, SHEL_PUT, SHEL_FIND, SHEL_ENVRN

BUGS

Ahum.

After all this splendour,  I must confess that I found some  bugs 
in GfA 3.0 There aren't many (two to be exact) but they are  both 
quite annoying...

The TRIM$ command bombs out on you when you try to TRIM an  empty 
string  or  a  string  containing  spaces  only.   This  sort  of 
eliminates the value of the TRIM$ command, because you still have 
to check for spaces in a string before you can TRIM it.

The INSERT, DELETE, QSORT and SSORT commands for arrays that have 
one-byte  (postfix |) variables will crash  hopelessly.  This  is 
bad,  because I wanted to write a super-duper input routine  that 
used a byte array to store the input, and INSERT and DELETE could 
have been very useful here.....

CONCLUSION

This  is the most complete ST-dedicated programming language  yet 
created.  Everything  you ever want to do can be done  using  GfA 
3.0,  and the term BASIC can be abandoned from now on. The manual 
is  very  extensive (dutch translation by Bert Rozenberg  and  W. 
Kerkhof).  The disk is filled with sample programs and  completed 
with a Recource Contruction Set with GfA-compatible output. 

STOP THIS CRAP AND BUY IT!!!

uh...yeah....sure....(it's great)

BYE!

Stefan

Info:

MARKO SOFTWARE
Jos. de Jongstraat 32-34
3314 VB DORDRECHT
HOLLAND

Disclaimer
The text of the articles is identical to the originals like they appeared in old ST NEWS issues. Please take into consideration that the author(s) was (were) a lot younger and less responsible back then. So bad jokes, bad English, youthful arrogance, insults, bravura, over-crediting and tastelessness should be taken with at least a grain of salt. Any contact and/or payment information, as well as deadlines/release dates of any kind should be regarded as outdated. Due to the fact that these pages are not actually contained in an Atari executable here, references to scroll texts, featured demo screens and hidden articles may also be irrelevant.