You will be aware that an application appears in the form !Name which you double-click to start. You probably know also that this is really a special directory which you can open by holding down the Shift key while double-clicking on the icon, and inside is a number of files such as !Boot, !Help, !Run, etc. At this point we are going to introduce a very cut down and simple program to run on the desktop, but even a simple program has a minimum number of components, so we need to delve into a little more theory before we proceed.

The application folder for Secrets
Because this article is available on this website, we can cheat a little and provide a simple shell containing some pre-coded elements, so that we can concentrate on the main program. Nevertheless, we will pause to explain what is contained in the shell. It is actually quite useful to keep such a shell on your harddisc to start building new applications from anyway. Remember that we shall be developing a program to store secret information, so from the beginning we shall call our program Secrets, and most of the files we start with will remain unchanged in the final version.
Click here to download the Secrets shell.
Our application begins with just five files already set up for you. They are
!Boot
!Run
!Sprites
!Sprites22
WLibrary
!Boot is an Obey file which is executed when the filer first sees the application, usually the first time you open the directory containing the application. Strictly, an application does not have to have a !Boot file, but it does ensure that the sprites for the application are recognised and appear correctly in any directory displays. The file contains the following lines:
| !Boot file for Secrets.
|
Set Secrets$Dir <Obey$Dir>
IconSprites <Obey$Dir>.!Sprites
The first two lines are comments denoted by the vertical bar |.
Line 3 sets Secrets$Dir to be <Obey$Dir>. These are called system variables (see your User Guide for more information) in this case identifying the pathname of the application being run.Thus if Secrets is in the root directory $, then <Obey$Dir> would be something like "ADFS::HardDisc4.$.!Secrets" depending of what you call your harddisc. The last line then uses the same method to tell the filer where to find the icon sprites for the program.
This is another Obey file which is executed whenever the application is started by double-clicking on the application !Secrets. As with the Boot file, it is very short and contains only two lines that do anything:
| "Secrets - AU version"
| Autumn 2000
Set Secrets$Dir <Obey$Dir>
IconSprites <Obey$Dir>.!Sprites
WimpSlot -min 32K -max 32K
Run <Obey$Dir>.!runimage
The first two lines are comments indicated by the | character and are ignored. The third line ensures that Secrets$Dir points to this copy of Secrets, and the fifth line tells RISC OS to set aside 32K of memory to hold our program, and the last line tells it to run a file called !runimage which will be our actual BASIC program.
These are normal sprite files, containing the sprites needed by the application. The sprites in !Sprites are used in 16 colour modes, but most users now work in 256 colours or more, and in this case the filer will automatically look for the more sophisticated versions in !Sprites22. (If Sprites22 is not present then it will revert to the simple versions in !Sprites.)
The names of the sprites in these files are very important. The large icon must have the same name as the application itself, but all in lower case: !secrets. A smaller icon for directory displays must have the same name preceded by 'sm': sm!secrets. A third sprite in the file will be used by the program later. It is put in now for convenience and is called banascret.
The sprites in !Sprites22
The fifth file is called WLibrary, and is a Library file. It contains a number of commonly used basic routines that can be called by our program when it needs them. Libraries are particularly useful when developing BASIC programs because they save so much time. Rather than repeatedly adding in frequently used code, you just include your standard library of routines.
In this series we shall again be cheating slightly by using the Library to include elements of code to keep the modules simple. Rather than explain every piece of code immediately, the more complex bits have been hidden away in the Library for the time being. Eventually we will substitute a smaller, more realistic Library that you will be able to use in your own programs later.
Now we can begin the program itself. Using Edit as before, copy the following code and save it as !runImage in the !Secrets directory. It is a little long, but you don't get programs that run in the Wimp for nothing!
REM Secrets
REM Encryption of confidential information
REM Version 1.00 Acorn User
REM (C) Chris Wragg 1998, 2000
LIBRARY "<Obey$Dir>.Library1"
ON ERROR PROCerror(REPORT$+" at line "+STR$ERL)
DIM block% 255,message% 255
DIM texta% 12,textb% 20,textc% 20,textd% 20
DIM R5% 2
$R5%="R5"
quit%=FALSE
app$="Secrets"
SYS "Wimp_Initialise",200,&4B534154,app$
REM iconbar icon
iconbar%=FNcreate_icon(-1,0,0,68,68,&3002,"!Secrets",0,0,0)
REM Information window
info%=FNmake_info("Secrets","Number Encryption","Your name","1.00 - date 2000")
REM iconbar menu
DIM barmenu% 75
PROCmake_menu(barmenu%)
DATA Secrets,2,0,info%,Info,&80,-1,Quit
REM The Poll Loop
WHILE NOT quit%
SYS "Wimp_Poll",&31,block% TO reason%
CASE reason% OF
WHEN 6:PROCclick(block%!12)
WHEN 9:PROCmenuselect
ENDCASE
ENDWHILE
SYS "Wimp_CloseDown"
END
DEFPROCclick(win%)
REM Response to mouse clicks
CASE win% OF
WHEN -2:REM Click on iconbar
CASE block%!8 OF
WHEN 2: REM Menu button pressed
openmenu%=1:PROCshowmenu(barmenu%,!block%-64,228)
ENDCASE
ENDCASE
ENDPROC
DEFPROCmenuselect
REM To select items from a menu
sel1%=!block%:sel2%=block%!4:sel3%=block%!8
CASE openmenu% OF
WHEN 1: REM Iconbar menu has been selected
CASE sel1% OF
WHEN 1: quit%=TRUE
ENDCASE
ENDCASE
ENDPROC
Provided you have typed this in correctly, the program will now run without any problems. It doesn't do much, but it puts an icon on the bar, and when you press the Menu button over the icon it gives you a two-item menu. The first opens a window giving information about the program. The second enables you to quit the application.
Secrets running on the iconbar
Should you make any mistakes when entering the listing, an error routine has been included which should help you to find where you have gone wrong. You can find a line number in Edit by pressing F5, but remember that BASIC defaults to multiples of ten for line numbers, so if an error is in line 250 you enter 25 to find the line.
There are several new keywords and ideas in this code. See how much you can follow, given that the functions (FN) and the error routines are not in the listing itself - they are in the Library. We will explain all in the next Module!