Task: Learn to Pass Parameters to Procedures in FastBasic
Needed: Web Browser, Altirra Emulator
Time: 15-30 mins
I have previously posted and introduction to a modern BASIC for Atari 8-bit computers called FastBasic. One of the nice features of FastBasic is the ability to define and execute procedures. Version 4.5 was released in 2021 and includes the ability to pass parameters to procedures. The general format is:
PROC name parameters(s)
your code here
The parameters are treated as global variables available anywhere in the program with values set using the EXEC command which executes the procedure:
EXEC name value(s)
Below (left) is a comparison of the FastBasic code from the previous post for summing several numbers stored in an array using a procedure. Below (right) is the code using procedure parameters with values specified in the EXEC command as summarized above. Note the code efficiency we gain for this task which was already a big improvement over Atari BASIC as highlighted in the previous post.
First, read the previous post for instructions on how to use FastBasic.
Second, download the ATR file with FastBasic version 4.5.2 and the SUM and NEWSUM code examples shown above in the figure.
Third, boot the ATR file in Altirra (or on original hardware), load the NEWSUM.FBA file, and try out the example.
Here is a zip file with text files for the two FastBasic examples.
FastBasic just keep getting better and better. The ability to pass parameters to procedures is an important new feature. It is really nice these are treated as global variables. This is becoming a serious BASIC programming language for the Atari 8-bits.
Here is an Atari Age thread with discussion of the new version 4.5.