MessageTrans Tester
by Alan Wrigley

This simple application is designed to demonstrate how to use the MessageTrans module in your own programs. For more information on MessageTrans, see this month's copy of RISC User magazine.

Running the application installs an icon on the icon bar in the usual way. The icon bar menu has four options: the usual Info and Quit, plus Black and Red. Choosing either of these latter two options will force the text display in the program's main window to be rendered in that colour.

Clicking Select on the icon bar icon opens the main window. This contains a single indirected icon at the top of the window, and six lines of text below.

The purpose of the program is to demonstrate how the text in both the icon and the rest of the window, and also the menu options, can be changed just by altering the !MsgTest.Messages file. If you look at this file, you will see that it contains a list of tokens, each associated with a text string. As described in the magazine article, by using the appropriate SWI calls a token can be translated into the correct string at the time the program is run, and hence the strings can be altered in the Messages file without touching the program itself. This method is used to convert applications for use in other languages.

All the token-to-string conversion is done in lines 860-1120 of the !RunImage program. The SWIs are all described fully in the magazine article. Note that lines 890-930 transfer the text associated with the token "ICON0" into icon 0, and therefore the icon's indirected text buffer is specified in R2 at line 910. The text strings in the rest of the window, however, are merely read from the file into an array str$(), and therefore a value of zero is passed in R2 at line 950.

You will also see that the window handle for the info box must be inserted into the completed menu structure after MessageTrans_MakeMenus has done its work, as described in the article. This is done at line 1130.

Try altering any of the text elements in the Message file, and then run the program again. You should see the changes reflected in the window or menu as appropriate. In particular, note the way the menu width changes to accommodate the items specified. If a menu item is longer than 11 characters, you will need to alter the icon flags in the appropriate line from &7000021 to &7000121.

 RISC User 1992
