BBC Micro – Organising Files on a Disk

This tutorial is the second of a set of lessons/tutorials that will focus on:

BBC Micro Online Emulator

To complete these lessons, you do not need access to a physical BBC micro computer. You can use the following online emulator and type commands in your browser, without the need to install anything on your computer.

You may also find the following BBC Basic emulator quite handy for testing your own BBC Basic programs.

Using Floppy Disk Drives

If you are using a physical computer, remember that the BBC Micro model B does not come with a hard drive to save your work. It is possible to connect a floppy disk drive to save your work on a 5.25″ Double Density floppy disk. Depending on the model of your BBC Micro, you may be able to connect it to a 3.5″ floppy disk drive to use with Double Density (DD) floppy disks with a capacity of around 1MB. This is probably a more reliable solution.

💾 Disk Filing Systems (DFS and ADFS)

The original BBC Micros used a DFS (Disk Filing System) which means they used a flat file structure with a single catalogue of files on the disk. On a DFS system, it is not possible to create a true hierarchical structure using folders/directories.

There is a concept of a directory qualifier — a single letter prefix that groups files (e.g., W.MEMO means file MEMO in directory W which could stand for WORK for instance where G.RACING could be used to store a racing game in directory G for GAMES). This looks like folders but is purely a single-letter categorisation mechanism rather than a true nested directory structure.

With a standard BBC Micro (DFS), you cannot have multiple levels of directories with standard BBC DFS — it’s all in one flat catalogue (with a maximum of 31 files per disk). Also filenames need to be 7 characters or less.

More recent BBC Micros benefited from a more advanced filing system called ADFS (Advanced Disc Filing System) — an upgrade that supports real hierarchical folders/directories, structured in a tree (folders and sub-folders).

This was available on later BBC Micros and upgrades, and later machines like the BBC Master.

💾 Creating, Saving and Loading files on a BBC Micro (DFS)

On the BBC Micro, the main disks operations such as viewing the content of the disk use special commands (starting with *).

📂 Viewing What's on the Disk
For instance to see what files and folders are on the current disk, use the following command:

*CAT

This will show a list of files on the disk.

To simulate opening a directory and hence focus on showing the files from the same group (using the same directory qualifier) use the following command:

*DIR W
*CAT

This would show all the files with the prefix W.

✏️ Typing Your First Program
Using the commend prompt, type the following code (including the line numbers):

10 MODE 2
20 COLOUR RND(7)
30 PRINT "HELLO WORLD"
40 GOTO 20

This program is written in a language called BBC Basic, a language created with the aim of making computer programming accessible to beginners through a simple yet powerful language on the BBC Micro computer.

You can now run this code by pressing the following command:

RUN

⚠️ To stop this program, press the BREAK key on the keyboard.

💾 Saving Files

After typing and testing your program, you will want to save it to the disk. Use the following command to do so:

SAVE "HELLO"

It will be saved on the disk with the filename HELLO.
⚠️Remember, on the BBC Micro file names cannot exceed 7 characters!

To save this file into a specific group (such as your WORK group: W):

SAVE "W.HELLO"

This saves HELLO within the W group. Remember groups are an alternative to the use of folders/directories as these cannot be created within a standard BBC Micro (DFS).

📃 Loading a Program into Memory
To load the program:

LOAD "HELLO"

This copies the program from disk into the computer’s memory.

You can check it loaded by typing:

LIST

You should now see your program lines on the screen.

▶️ Step 3: Run the Program
To run the program after loading it:

RUN

Your program will now start.

⚡ Quick Way: Load and Run in One Command
You can also load and run a program in one step using:

CHAIN "HELLO"

This is very commonly used for games and larger programs.

✏️ Renaming Files
To rename a file:

*RENAME oldname newname

Example:

*RENAME HELLO TEST

This renames file HELLO to TEST.

⚠️ Be careful — if the new name already exists, it may overwrite it.

🗑 Deleting Files
To delete a file:

*DELETE filename

Example:

*DELETE OLDGAME

⚠️ Deleted files cannot be recovered.

✏️ Editing a Program
If you want to edit an existing progam, you first need to make sure it is already loaded in memory:

LOAD HELLO

Then you can view the code of this program using the following command:

LIST

✏️ To change an existing line of your program

If your program has:

10 PRINT "HELLO"

and you want to change it to say:

10 PRINT "HELLO WORLD"

Just type:

10 PRINT "HELLO WORLD"

and press RETURN.

Line 10 is now replaced.

➕ Adding New Lines

To add a new line between 10 and 20, use a number in between:

15 PRINT "WELCOME!"

BBC BASIC keeps the program in number order automatically.

️➖ Deleting a Line

To delete line 15, type:

15

and press RETURN.

That line is removed from the program.

📃 Listing Part of a Program

To see only part of the program, type the following command:

LIST 10,50

This lists lines 10 to 50 only. This is very useful when working on a long program.

💾 Saving Your Changes

After editing, save again to keep your changes:

SAVE "HELLO"

This overwrites the old version with the new one.

⚠️ If you want to keep both versions, use a new name:

SAVE "HELLO2"

⭐ Extra Tip: Renumbering Lines

If after inserting and removing lines, your line numbers get messy, you can renumber the whole program:

RENUMBER

or even better, using the following command:

RENUMBER 10,10

(start at 10, count by 10)
This makes it easier to insert new lines later.

Your Task

Use all of the above commands to recreate the following file structure on your BBC Micro Computer or using the online emulator.

D.HELLO
D.SPLASH
W.TIMES
W.MOON
W.PASS

In the above file structure D stands for DEMO and W stands for WORK.

Our four files will contain the code provided in the four tabs below:

D.HELLO fileD.SPLASH fileW.TIMES fileW.MOON fileW.PASS file
D.HELLO file:
A colourful “Hello World” program.

10 MODE 2
20 COLOUR RND(7)
30 PRINT "HELLO WORLD"
40 GOTO 20
D.SPLASH file:
This code is a demo of a splash screen using blinking red text.

10 MODE 7
20 PRINT CHR$(136)CHR$(129)"SPLASH SCREEN!"
W.TIMES file:
A program used to generate a times table:

10 REM Times Table Generator
20 INPUT "Enter a number: " ; n
30 PRINT
40 FOR i = 1 TO 10
50   PRINT n; " x "; i; " = "; n*i
60 NEXT
W.MOON file:
A program to caluculate you weight on the Moon!

10 REM Weight on the Moon Calculator
20 INPUT "Enter your weight on Earth in kg: " ; weight
30 moon = weight / 6
40 PRINT
50 PRINT "Your weight on the Moon would be:"
60 PRINT moon; " kg"
W.PASS file:
A program used to generate a random password:

10 REM PASSWORD GENERATOR
20 password$ = ""
30 FOR i = 1 TO 8
40 r = RND(36) - 1
50 IF r < 26 password$ = password$ + CHR$(65 + r) ELSE password$ = password$ + CHR$(48 + r - 26)
60 NEXT
70 PRINT "Password: "; password$

Did you like this challenge?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!