First Steps in Programming
RISC OS Computers
Martyn Fox

Introduction

How do you go about learning to program? Isn't it necessary to learn lots of complicated code numbers and things like that? Not on this machine. It may seem very complex, with pretty icons whizzing about all over the screen, but getting started is actually very simple indeed, thanks to the language that is built into the machine. What this means is that you can give it instructions in a form remarkably similar to English. This language is called Basic, and because your machine has an enhanced version of the type of Basic originally produced for the BBC microcomputer which was first manufactured by Acorn Computers Ltd. in the early 1980s, its correct name is BBC Basic.

What is RISC OS?

You will still find frequent references to Acorn computers in magazines and software adverts, and may even occasionally find a reference to the 'Archimedes'. This was the name given to the first generation of Acorn 32-bit computers. You might even be using one now, as they do last a long time. Rest assured that all the software described in this guide should run on it.

Acorn themselves ceased developing and manufacturing computers in 1998 but Acorn-badged machines continued to be produced by Castle Technology Ltd. Computers using the same technology were also developed by other companies such as RiscStation and Microdigital.

All these machines, from the original Archimedes onwards, have the same operating system. This is the software which is built into the machine and makes it go. Because it is stored on a ROM (Read Only Memory) chip, it's there all the time and starts working as soon as you switch on the machine. This operating system is called RISC OS (Reduced Instruction Set Computer Operating System). Basically, any software that runs on a RISC OS machine should run on yours, unless it has some special requirement and, likewise, anything you write should run on another RISC OS machine. All the programs in the original printed book version of this guide, and indeed the book itself, were produced on a second-hand Archimedes A310, which was manufactured in 1987.

The most likely special requirement that software might have is memory size. A lot of major packages require a minimum of 4 megabytes (written 4 Mb) of RAM (Random Access Memory). Software for handling graphics frequently requires a lot more.

None of the software that we'll be creating requires anything like even 1Mb however, so this needn't trouble us.

This guide doesn't cover the writing of programs using windows and menus. As we saw in the preface, these are rather complicated and best left until you have mastered the Basic language. When you've mastered everything in this guide, you'll be ready to tackle A Beginner's Guide to Wimp Programming which will teach you how to create professional-looking applications. We will, however, create a simple multi-tasking 'front end' for a program which will run in the desktop environment, with its icon on the icon bar.

Plumbing Hidden Depths

The machine's desktop, with its windows, menus and the mouse pointer doesn't seem to offer us much opportunity to give it instructions, so how do we go about it?

You can write a Basic program using a text editor, such as Edit (which is built into the machine) or the freely-available applications Zap and StrongEd. We'll be doing that shortly, but we'll take our first steps at a lower level.

We're going to start by using Basic's command level, also known as immediate mode. In this mode, when you type in a command for Basic to do something, it does it immediately, without you having to save a program and run it.

Assuming that you're following this guide on the screen, rather than a printout on paper, you'll have to remember the next bit while you try it out:

Press the right-hand function key, labelled F12. The desktop will move up the screen and a white line will appear at the bottom. The desktop will have turned into a frozen image and the mouse pointer will have vanished.

On the left-hand side of the white line will be a black star. That star is the key to plumbing hidden depths in your machine. The flashing black line to the right of it is the cursor - it is an invitation to type something in and shows where it will appear on the screen.

... a white line will appear at the bottom

... a white line will appear at the bottom

For the moment, though, how do we get back to the nice, friendly desktop? Don't panic, just press the Return key. Provided you didn't type in anything following the star, the desktop will return to normal and the pointer will reappear. If you did type in something, you will probably get a message saying 'File not found', or saying that you made some sort of mistake, followed by another star. In this case, just press Return again. Try it.

Are you back with us? That line with the star at the beginning of it was the machine's command line. The commands that we type in here, because they are preceded by a star, are known as Star Commands.

You can't be expected to memorize everything that this guide tells you to do on the command line, though, so you'll need another way of using the command line; one which doesn't stop the desktop working.

The Task Window

If you press Ctrl-F12, a window will appear on the screen labelled 'Task Window', with the star prompt in the corner. In place of the flashing black cursor will be the red caret, probably familiar to you from word processing and writable icons.

This is actually a window belonging to the Edit application, which is why the Edit icon will have appeared on the icon bar. It's different, though, because the operating system has started up a new application and this window is linked to it.

'Task Window', with the star prompt in the corner

'Task Window', with the star prompt in the corner.

previousmain indexnext

 
© Martyn & Christine Fox 2003