Programming Tips

By Gus Donnachaidh

Originally published in EUG #33

Memory Scrub

Sometimes when you're developing a program, it's useful to be able to wipe an area of memory to be sure that old data is not affecting the way the program is running.

This short line will put a 0 into every memory location set by the FOR...NEXT loop:

      >*KEY0 FORA=&E00TO&4000:?A=0:NEXT|M

The number &E00 is PAGE on the Master so, for the Elk, this might be &1D00. On the BBC, it's &1900. The number &4000 is the beginning of the screen memory. ?A=0 is BBC BASIC's way of saying poke 0 into location A and since A starts at &E00 and cycles up to &4000, every location will have 0 poked into it. |M is simply RETURN and will cause the routine to run as soon as function key 0 is pressed.

Almost any addresses can be used and the screen could even be wiped in this way. Some addresses will cause the computer to lock up but this will not do the computer any harm at all. And if you happen to wipe area &B00 to &B38 the routine itself will be wiped and the computer will, not unsurprisingly, hang.

Changing Drives In ADFS

Some people brought up with DFS are put off ADFS by the number of key presses needed to change drives and directories.

You have a disk in drive 0, $ directory, subdirectory A then, in A, there is a further subdirectory, B.

Disk in drive 1, $ directory, subdirectory C and, in C, there is a further subdirectory D.

You are working on a file FRED in directory B and you want to move it to directory D. Type:

      >*DIR :1.C.D (RETURN)

You always need a colon before a drive number and a period before a directory name. Apart from that, it's really easy and a lot easier than the manual's instructions: *MOUNT 1 (RETURN), *DIR C (RETURN) and *DIR D (RETURN).

This routine can also make changing disks easier.

If you have a single drive and you are working on a file in directory B as before and you want to save it onto a different disk in directory D, put the new disk into the drive and type:

      >*DIR :0.C.D (RETURN)

Printing Text Files

This routine has been in EUG before but is well worth repeating, particularly if you're one of the many who have problems with the EUG printing routines. It was sent in around EUG #16 by someone. I'm sorry to say I've forgotten who.

      10*LOAD TEXT 2000
      20VDU14:PRINT"Press <SHIFT> to scroll"
      30FOR B%=&2000 TO &3F00
      50CALL &FFE3

Ideally the length of the text file should be added to &2000, and this figure put in, in place of &3F00. If you type *EX (RETURN), the length is the third sequence of numbers. Type:


Gus Donnachaidh, EUG #33