HINTS & TIPS

This months collection of hints and tips is rounded up by David Spencer and Lee Calcraft.

A NOVEL USE FOR THE DESKTOP DUSTBIN*

The RISC User Desktop Dustbin, featured as a public domain bonus on last month's magazine disc, can be used in a novel way when saving files. How often have you traversed several menu levels to get the save icon, only to find that you haven't got a directory viewer open. Rather than starting all over again, simply drag the file into the dustbin. Then, open the appropriate viewer and the Dustbin, and drag the file back out of the bin.

ASSEMBLER FROM C

Release 2 of the Acorn C compiler allows the object code to be output in the form of an assembler listing rather than an object file. To do this, add the switch -s to the command line. You may also find it useful to add the switch -ff which will stop function names being included, as these tend to confuse the situation. So, for example, the command:
cc testprog
would become:
cc -s -ff testprog
The resulting assembler code is saved with the same name as the source, but in the directory s. The listing is in a form suitable for Acorn's OBJASM assembler. The main purpose of this feature is to allow you to 'hand-prune' the code, but it is also interesting to look at how C compiles code.

DESKTOP MOVE*

Normally, when you drag a file from one directory viewer to another in the RISC OS Desktop, the file is copied rather than moved (in other words the original is still intact). On the other hand, if you hold down the Shift key while dragging the file, the original will be deleted after the copy, thereby performing the equivalent of a move.

SERIAL TRANSFERS

Perhaps the quickest way to transfer a file to another computer through the serial port is to use the command:
*COPY <filename> Serial:
which copies the named file to the serial port. Similarly, a file can be received using:
*COPY Serial: <filename>
Obviously the correct baud rate and data format must have been set up using *CONFIGURE, or the appropriate *FX commands.

CONFIGURE OPTIONS*

Most of the *CONFIGURE options which control memory allocation (SCREENSIZE etc.) can take the value in kilobytes (by including 'K' after the value) as well as pages on RISC OS. The new form should be used in preference as it is independent of the page size of the memory. For example, the 300 series has an 8K page size, and therefore *CONFIGURE SCREENSIZE 20 would reserve 160K, while the 400 series has a 32K page size so the same command would reserve 640K. However, *CONFIGURE SCREENSIZE 160K would have the same effect on all machines.

MOVED FONTS*

Under Arthur 1.20, any memory reserved for the Font Manager (using *CONFIGURE FONTSIZE) was claimed from the relocatable module area (RMA). With RISC OS, the font memory now has its own 'chunk' which starts at logical RAM address &1E00000. One effect of this is that whereas font memory could previously be allocated in 4K blocks, it is now reserved in whole pages (8K on 300 series, 32K on 400 series). This does not however affect the values used with *CONFIGURE FONTSIZE.

PC PARTITIONS

If you create a partition on a hard disc for the PC Emulator, then this appears to the Archimedes as a large file called 'Drive_C' in the directory 'PC'. You should be very careful not to delete this file, as it would result in all the MS DOS files on drive C being lost. However, don't try to lock the file using *ACCESS because this will prevent the Emulator from saving anything on drive C.

CURSOR ON/OFF PROBLEM

As you may be aware, the cursor may be turned on and off from Basic with the two keywords ON and OFF. To do the same from machine code, there are two SWI calls which have a very similar effect:
SWI "OS_RemoveCursors"
and
SWI "OS_RestoreCursors"
And like all SWI calls, they may be issued from Basic as SYS calls (e.g. SYS "OS_RemoveCursors").

But beware if you are mixing machine code and Basic, because if you turn the cursor off with OFF, the SWI (or SYS) call to restore it will not do the trick, and by the same token, if you turn the cursor off with the SWI call, you cannot use ON to re-instate it.

This leads to the odd situation that the cursor can be doubly turned off by using OFF followed by its SWI equivalent. You will then need to issue both ON and its SWI equivalent before the cursor returns.

SWI NAMES AND NUMBERS

Two SWI calls are provided for converting between SWI numbers and their names:
"OS_SWINumberToString"
and
"OS_SWINumberFromString"
The program below gives an example of their use. Line 40 places in the variable numb the SWI number of "OS_RemoveCursors", while line 70 performs the reverse, taking as an argument the value &36 (the SWI number for "OS_RemoveCursors", and the succeeding line displays the result.

10 REM > SwiTest
20 :
30 DIM out &20
40 SYS "OS_SWINumberFromString",,"OS_ RemoveCursors" TO numb
50 PRINT "&";~numb
60 :
70 SYS "OS_SWINumberToString",&36,out,&20 TO ,swi$
80 PRINT swi$

WHICH FORMAT?*

RISC OS provides the user with a new ADFS disc format which avoids the need for periodic disc compacting. The new E format is the default on machines with RISC OS fitted, but is unreadable on machines running under Arthur. To find out whether a disc is D or E, or the older L, format, use the command *MAP. On a RISC OS machine this will display the following words:
L format"old map, old directories"
D format"old map, new directories"
E format"new map, new directories"

Under Arthur, the only way to distinguish between L and D formats is to use *FREE and work out the total disc space. This is 640K for L format and 800K for D format. Thanks to Barry Christie for this hint.

SHOWING FILE TYPES*

The command:
*Show File$Type*
will list the file types currently known to the operating system. This is useful in itself, but you can add your own by using the system variable File$Type. For example, to set up file type &1FF as My Data, use:
*Set File$Type_1FF My Data

Using *Show should reveal the new file type, and if you use *Info or *FileInfo on a file of this type, you will see the new type displayed in words (up to a maximum of 8 characters).

CASE STRINGS

CASE statements work equally well with numeric OR string variables. You can therefore use statements such as the following:
CASE fruit$ OF
WHEN "bananas":PROCbananas
WHEN "apples" :PROCapples
WHEN string$ :PROCvariable
ENDCASE

SKIPPING CODE

To skip a piece of code in a program under development, you can simply bracket it with:
IF FALSE THEN
.
.
ENDIF

This avoids inelegant references to line numbers.

Hints marked with an * are relevant to RISC OS only.