<aside> <img src="notion://custom_emoji/efbcdd14-c5f9-4858-9139-f95e30ef0c2e/1c863fde-aa7d-8041-9799-007addf3f467" alt="notion://custom_emoji/efbcdd14-c5f9-4858-9139-f95e30ef0c2e/1c863fde-aa7d-8041-9799-007addf3f467" width="40px" />
Prompted by Andy Taylor's Letter in Forum, STA 28, I decided I'd step forward and do a series of teaching BASIC for beginners. This series will concentrate on using GFA Basic V3.5E — the last version GFA produced (PC defectors...). The reasons are: 1) It's the only ST Basic I've used, and 2) It was free on a certain glossy ST Mag about eight months ago (!). Oh, and 3) It's fast.
Over about six issues, we will look at the building blocks of programming techniques and GFA Basic examples. At the end of each month's article, I will set a few tasks for you to be getting on with. Incidentally, all the programs listed for each article will be available on the next STA Disk Mag following that article. I will also put my own answers to the tasks onto the disk mag for those who perhaps need a bit of help and for the plain nosey.
To follow this tutorial effectively, you'll need an ST, GFA Basic V3 (V3.5E pref), ideally the GFA Manual, strong coffee and a bit of time. Over six parts, don't expect to be programming games, but do expect to understand how to break a requirement down into its component tasks, even if you can't yet write those parts in actual code. There are many other ST Basics, such as FAST BASIC, ST BASIC, FirST & Basic. The fundamentals of programming will be the same, but the commands probably won't. For the latter two, the ST Club sells a very good tuition book on how to program FirST Basic, and I can recommend this to FirST Basic owners.
</aside>
Well, we can start from the pretty safe assumption that you have all "programmed" before! It may not have been on a computer, but in everyday life, you are effectively programming your own actions. Going to the shops is a perfect example to explain computer programs — you write on the list a number of jobs to do. If you're more organized, you would write the list in order of the shops you need to visit. You may also write on this list a few notes to yourself that are not things to do, but to remember. Once you have obeyed everything on the list, you go home. A computer program is very similar. It is no more than a list of instructions that the computer "reads" from left to right, top to bottom. Once it gets to the end, it stops.
We are going to type in the first program into GFA. But first we need to run GFA Basic. I'm assuming that you have a copy of GFA Basic. If you bought it, or got it from the glossy mag, you need to copy GFABASIC.PRG to a blank disk and run GFABASIC from there. You can then safely save any programs we type in onto this disk, without fear of losing the original disk containing GFA Basic.
Make sure you are in ST Medium or ST High resolution. Double-click on GFABASIC.PRG and after a few moments you should have a white screen with two rows of black commands at the top of screen. (Note: GFA Basic works, sort of, on the Falcon, if you have one. Either go into ST Med or ST High emulations, or select 2 colours in the Video dialogue — GFA Basic should run then. There are a few other oddities however...). These top two rows are a bit like a menu bar: selecting them with the mouse makes things happen. We will be using the Load, Save and Run options later. For more details on actually using the editor, I must draw your attention to the GFA Basic manual, as I don't have the space to teach the way the editor works in detail here.

REM This is the first GFA Basic Tutorial Program
CLS
PRINT "Basic is quite fast really"
PRINT "It gets round the shops faster than me!"
END
REM Example Program 1.2
REM This is the first GFA Basic Tutorial Program
CLS
start:
PRINT "GFA Basic is quite fast really"
PRINT "It gets round the shops faster than me!"
GOTO start
Type in each of the lines from Fig 1.1 as you see it. At the end of each line, press RETURN. If you have made a mistake, GFA Basic will not let you leave the line until it is remedied — a handy feature, but also annoying when new to it! Once you have typed in the listing, move the mouse over Run and click the left button.
The two lines of message appear on the top of the screen, and an alert box has appeared to tell you GFA Basic has finished running the program.
So, what happened? Your program contained a list of 6 commands. The first two started REM. This means REMARK, or comment — it tells GFA Basic to ignore what follows on the line! Why? Well, it gives provision for you to put messages to yourself anywhere within a program and not confuse GFA Basic in the process — similar to messages to process yourself in the shopping list example earlier.
On the third line we see the command CLS. This is the first command GFA actually acts upon. This command means CLear the Screen. What it does is exactly that, it gives a nice white blank screen. GFA then moves to the next line. On this line is the command PRINT. This command tells GFA to write something on the screen. What is to be written is enclosed within marks. As you saw, the contents of that line appeared at the very top of the screen when you ran the program. GFA Basic then proceeded to the next line, another PRINT, and so the same thing happens. As you saw, the second PRINT caused the writing to appear underneath the first. The final command was END. This tells GFA that the program stops here and so GFA printed the Alert box to tell you it's all over.
If you want to save the program, select SAVE from the black menu bar at the top. A File selector appears. You need to tap in a filename under which to store this program, followed by ".GFA". The program is then saved onto your working copy disk.
For more information on PRINT, CLS and REM, see pages 131, 281 and 233 respectively in the V3 GFA Basic manual, although we will use them more in future episodes.
Finally this issue, we are going to introduce the idea of repetition. What has been described so far is the idea of reading a whole list to the end and then stopping. Repetition is the first of a number of standard programming concepts that make computers very good at doing certain tasks (and faster than us old humans!). There are many ways of getting GFA Basic to repeat parts of the program a number of times. The term to describe this is LOOPing, and the LOOP command is one of many that can be used, incidentally. Right now we will look at the most basic (and probably the most useless!) looping command. It does, however, serve a purpose to show an example.
Using the up and down arrow keys, move the cursor over the E of END in the program. Press the DELETE key, this erases the command END letter by letter. Instead type in the line "GOTO start". Now move the cursor up the screen to the line with the first PRINT statement on it. Press INSERT. A blank line is created and now type in "start:". See Example 1.2 for the new listing of how it should finally look. Now select Run from the menu (or press SHIFT & F10 together). This time you should see the two lines of writing appear continuously down the screen, and at the bottom it all starts to scroll upwards like the football scores typewriter on Grandstand at 5pm! And indeed it keeps going...