A problem in RISC OS frequently causes the SpriteUtils module to become unplugged when the new operating system is first installed. This module implements the sprite star commands, and therefore any program which uses system sprites will come up with an error such as:
File 'SLOAD' not found
Typing *UNPLUG will list the names of any unplugged modules, and if 'SpriteUtils' is among them the solution is to enter the command:
*RMReInit SpriteUtils
which will cure the problem once and for all. Of course, RISC OS programs should avoid using system sprites anyway.
With any utility program, it is very useful to be able to place it in the library directory and execute it when needed with a star command. This is particularly so for hard disc users who can build up a massive library of useful commands. The 'Run$Type' system variables allow such utilities to be written in Basic, but it is necessary to include some code in your program to read any parameters given to the command. The following procedure will do just this:
1000 DEF PROCparams
1010 DIM arg$(100):arg%=0
1020 SYS "OS_GetEnv" TO A$
1030 IF INSTR(A$,"-quit") THEN
1040 A$=MID$(A$,INSTR(A$,"-quit")+6)
1050 WHILE LEFT$(A$,1)<>" " A$=MID$(A$,2):ENDWHILE
1060 WHILE A$<>"" AND LEFT$(A$,1)=" " A$=MID$(A$,2):ENDWHILE
1070 WHILE A$<>"" arg$=""
1080 WHILE LEFT$(A$,1)<>" " AND A$<>"" arg$=arg$+LEFT$(A$,1):A$=MID$(A$,2):ENDWHILE
1090 arg$(arg%)=arg$:arg%+=1
1100 WHILE A$<>"" AND LEFT$(A$,1)=" " A$=MID$(A$,2):ENDWHILE
1110 ENDWHILE
1120 ENDIF
1130 ENDPROC
This will return with arg% containing the number of parameters, and the array arg$() containing the parameters, where parameters are taken to be space-separated. For example:
*PROG Hello Goodbye
has the two parameters 'Hello' and 'Goodbye'. Incidentally, the procedure must be called before any further star commands are issued.
When using RISC OS, be very careful not to accidentally copy a directory into itself. This can be done if you are dragging the directory's icon, and you inadvertently drop it into its own viewer. Because all Desktop copies are recursive by default, the directory will be repeatedly copied into itself until the disc fills up. If this does happen, press Escape to stop the operation, and delete all the new copies.
The new International Keyboard module included in RISC OS provides a very useful feature to allow any ASCII character to be entered at the keyboard. All you need to do is hold down either of the Alt keys, and type the ASCII code for the character on the numeric keypad. When Alt is released, the character will be entered into the keyboard buffer as if it had been typed directly. For example, Alt and keypad-44 will enter a comma, while Alt and keypad-128 will produce a square root symbol (also the WIMP's tick). Of course, this method would normally only be used to enter characters that cannot be generated directly from the keyboard.
Another feature offered by the International Keyboard module is the ability to switch between any of the available keyboard layouts with a series of keypresses. For example, pressing Alt-Ctrl-F1 will select the UK keyboard layout, while Alt-Ctrl-F2 will revert to the correct layout for the configured country. This can be very useful when, say, you have the Greek keyboard selected, if you need to switch back to the UK keyboard to enter star commands and the like.
Alternatively, you can select the keyboard appropriate to any country offered by pressing Alt-Ctrl-F12, and then, without releasing Alt, typing the international telephone dialling code for the country on the numeric keypad. For example, 39 for Italy. A list of dialling codes can be found in the front of The Phone Book.
When writing the code to redraw windows in a WIMP-based program, it is vital that the graphics origin remains at (0,0) across calls to Wimp_Poll, otherwise the entire system falls over. However, you can change it if you want, as long as it is changed back to (0,0) when the redraw code finishes.