SWI Manager - SWI management utility

by Alan Wrigley


SWI Manager was originally published as part of the Basic Programmers Toolkit, providing a comprehensive aid to programmers enabling them to:

 Convert any SWI name to its corresponding number and vice versa;

 Convert all the SYS calls in a Basic program to names, numbers or variables;

 List all the SWIs currently known to the computer.

The version supplied on the current disc is an updated version of the program, and includes the following additional features:

 List the SWIs that belong to any particular module currently installed;

 Click on a SWI name in the list and transfer it to the caret as a quick means of entering SWI names into program code;

 Save the SWI list as a text file.

Converting the SWIs in a program has a number of uses. For example, you may come across a program written by someone else in which the SYS calls are specified by number, which makes it difficult to understand the purpose of the calls without looking each one up as you come to it. Converting the program to names allows you to read the program more easily.

Conversely, having written a program yourself you may wish to convert all the SYS calls to numbers, since they operate more quickly that way and generally use up less memory.

Converting to variables gives you the best of both worlds. The program is instantly readable since the variables will have the same names as the SWIs to which they relate, but the speed of operation will be little different from that achieved when using numbers.

Using SWI Manager
Running the application installs an icon on the icon bar. The icon bar menu has just two items, Info and Quit, which perform their usual functions.

Clicking Select on the icon bar icon opens the main window. This is in three sections.

Single conversion
The upper section is headed Single conversion, and allows you to convert a SWI name into a number, or vice versa. Enter a SWI name into the writable icon labelled Name, or enter a number into the writable labelled Number, and press Return or click on the Convert icon. The appropriate conversion will be performed and the result entered into the other writable icon, using the following rule: if either icon is empty, the conversion will take place from the filled icon to the empty one. If both are filled, the conversion will take place from name to number, i.e. in the order in which the icons appear in the window. Note that when converting from name to number, the name must match a known SWI exactly, including case matching. If it is incorrectly typed, or the computer cannot currently find a module that recognises the SWI, an error is generated. If on the other hand you enter an unknown number into the number icon, the name icon will show "User" or "XUser".

Program conversion
The central section of the window is headed Program conversion. Dragging a Basic program into the window or onto the icon bar icon will convert all SYS calls in that program to names, numbers or variables according to the state of the radio icons in the window at the time the file was dragged. If the conversion is to names, they will be presented in the usual way, e.g.
	SYS "Wimp_OpenWindow"
If the conversion is to numbers, they will be given in hex, e.g.
	SYS &4610A
If the conversion is to variables, then the SWI name will be converted directly to an integer variable of the same name, including case matching. For example, SYS "Wimp_Initialise" (or its number equivalent &400C0) will be converted to:
	SYS Wimp_Initialise%
In this way, a program which has been converted to variables can be converted back later to names or numbers.

Since variable names are not recognised as SWI names when executing the program, conversion to variables requires a further process. SWI Manager adds a procedure called PROCswivariables to the end of the program. This procedure contains all the SWI variables used with the correct values assigned to them, e.g.:
	Wimp_OpenWindow%=&400C5:OS_WriteN%=&46

A call to PROCswivariables is added near the start of the program, after the last initial REM line. Note that if the program is later converted back to SWI names or numbers, neither the new call nor the new procedure is removed from the program. This means that if you subsequently convert it to variables again the new sections will be duplicated.

SWI list
The final section of the window allows you to list SWIs currently known to your computer (i.e. all those recognised by modules which are currently resident). You may specify the start and end SWI numbers for the search by entering the values into the two writable icons, or you can click on the Choose module menu button and select a module from the list. Clicking on the List icon will open a window showing all the SWI numbers and their names between the values given in the start and finish icons.

Once the List window is open, you can click on any SWI listed to insert its name into any document that has the caret. So if you are editing a program, you can use this feature to enter long SWI names without having to type them in yourself.

Clicking Menu over the SWI list window opens a menu with one option: Save list. This leads to a standard RISC OS save box that allows you to save the contents of the SWI list as a text file.


Copyright  RISC User magazine 1998