From Atari Wiki
Jump to navigation Jump to search

The Environment

Before you start coding, you should familiarize yourself with the GFABASIC system itself. Don't worry, at the end of this chapter you will write your first GFABASIC program. So let's start with simple things. From now on I assume basic knowledge of the Atari ST computer, how to handle the mouse, how to navigate menus and dialog boxes and howto run programs from the desktop. Getting into GFABASIC

Before coding you need to get into GFABASIC for obvious reasons. Simply doubleclick GFABASIC.PRG and the ST should load the interpreter. You should get a picture like this one after loading GFABASIC: [image of GFABASIC editor]

This is your main working environment, the GFABASIC editor. Here you are going to write your programs, save them to disk and finally run them. You can run the interpreter from any screen resolution but keep in mind that without special measures your program will run in the initial one. The editor however will switch into ST-MED if run from ST-LOW. Above I've started GFABASIC from ST-LOW. In the editor you won't see that but in the direct mode or while running your program you will see the desktop resolution. Now relax - you will discover that you can use the mouse as normal. The green (or in ST-HIGH black) cursor awaits you to type commands. If you are used to other BASIC dialects like STOS note that you do not need to precede your commands with line numbers. Infact the GFABASIC editor will complain if you try to.

The button bar

As you can see the top of the screen is claimed by a button bar in 2 rows. Don't worry - it will not be visible when you run your programs. The main actions are accessible from there. Simply click an action with your mouse to activate it. But much more easy is the use of the function keys. If you count the actions, you see 20 different actions in this button bar. Press F1 to F10 to activate them. Each column on the bar stands for one F key. You wonder how that will work? 10 F keys and 20 options? Piece of cake - if you press an F key alone, it will activate the function of the lower bar. Press F1 to activate LOAD for example. To access the functions of the upper bar hold the SHIFT key and press then the according F key. Shift+F3 will quit the interpreter to the desktop for example. Click on the clock to set the time. The number below the clock shows you the current line number in your program. For full documentation of the various options see a GFABASIC manual. I'll only cover options as needed by this tutorial here. Basic editor usage

Move around the editor with the cursor keys. Most other editor keys like Clr/Home will act as you thought so basic editing is easy and straight forward. Click on INSERT or press F8 to toggle between insert and overwrite mode. Pressing Insert is special as it will insert a blank line to add code instead of toggling insert mode.

Having typed some code you surely will save it to disk for later use. To save your current program, click SAVE or press Shift+F1. A fileselector will appear. Give a name for your program and click on Ok to save. The extension .GFA will automatically be added. If you have already saved your program under this name, GFABASIC will automatically backup your old file, giving it the extension .BAK, before overwriting with the new version. If something went terribly wrong, you'll always have a .BAK to recover your source from.

To load your program again, click on LOAD or press F1. The fileselector will appear. Select the program you want to load and click Ok. Loading a program will erase the old one in memory so make sure to save your other program first.

A free quote by Roberta Williams of Sierra fame: "Save early, save often!" It is a wise step to save your work before running. If the ST crashes, you'll still have a copy on disk to recover your work. There is nothing more ugly than loosing the work of hours by forgetting to save it first. (And I *do* talk out of experience here!)

If you want to save your work to share it on the internet, click on SAVE,A instead or press Shift+F2. This will save your whole program as ASCII text that you can easily mail or post on the net. GFABASIC will give a .LST extender to plain ASCII files and will not make a .BAK copy of old .LST files.

To load a .LST file, click MERGE or press F2. Select the .LST you want to load and of you go. MERGE is special in the way as it really merges. This means it does not erase the program in memory but it inserts the contents of the .LST file at the current cursor position. This allows you to build libraries and merge them when you need them. If you want to load a .LST that contains a complete program, make sure to do a NEW first to erase the old one in memory.

To erase the current program in memory, click on NEW or alternatively press Shift+F4. Click LLIST or press F3 to print your current code on the printer. Click QUIT or press Shift+F3 to leave the interpreter. It will drop you to the desktop or the calling shell in some instances.

Your first GFABASIC program

Of course this tutorial uses the famous "Hello World" as the first program here. Type the following line of code into the editor. GFABASIC should not complain. If it does, check carefully for typing mistakes.


Whew, that was easy. Your first GFABASIC program and now you are going to run it. Save it first. Then click RUN or press Shift+F10 to finally execute your program. This will make GFABASIC leave editor mode and execute your program. Having done this, the screen should look like this one: [image of first GFABASIC program running]

Neat, huh? The box in the middle of the screen always appears when your program terminates as long you don't tell GFABASIC to return directly to the editor again. You will learn about that later on. Check the dialog and GFABASIC will drop you back into the editor.

While developing your program you can always run an even unfinished program. Make sure no logical errors or missing statements are in and you are safe to try out. This makes GFABASIC so nice to use. GFABASIC will detect errors while running and it will ofcourse complain to you.

This concludes your first lesson in GFABASIC. By now you should have learned how to type a program into GFABASIC, how to save and load it again and how to finally run it.

back to the GFA Tutorial