[comp.sys.acorn] Useful utils.

nbvs@cl.cam.ac.uk (Nicko van Someren) (02/19/91)

O.K., I know that we are not suposed to be posting code to this group but these
utilities are so short and so handy to have that I thought I would post them
anyway.

Here are the sources to three utilities I have writen.  The longest is 56 bytes
and the other two are both 28 bytes.  They are called Do, IfDesk and Input.
The code here should be assembled and saved with file type Utility (&FFC).

*Do takes the command tail, passes it through the OS_GSTrans call and then
executes it.  This is hand for a number of things, the best use I have found
is to give an application directory the run file "Do Filer_OpenDir <Obey$Dir>"
Which has the effect of opening the application directory when it is double
clicked.

MOV     R0,R1
MOV     R1,R12
MOV     R2,#&0100
SWI     "XOS_GSTrans"
MOVVC   R0,R1
SWIVC   XOS_CLI
MOV     PC,R14

*IfDesk passes the command tail to OS_CLI is the command is executed while the
desktop is running and does nothing otherwise.  This can be used to make obey
files do different things deppending on if you have run them from your main
boot file of if they have been executed because of the filer opening a viewer.

MOV     R0,#0
SWI     "Wimp_ReadSysInfo"
MOVVS   PC,R14
CMP     R0,#0
MOV     R0,R1
SWINE   "XOS_CLI"         ; SWIEQ for *IfNotDesk
MOV     PC,R14

*Input takes the name of a system variable and does what you might expect.
An application of this might be as follows:

*Echo Which host (<Default$Host>)?
*Input Use$Host
*If "<Use$Host>" = "" then Set Use$Host <Default$Host>
*Do Telnet <Use$Host>

MOV     R5,R1
MOV     R0,R12
MOV     R1,#&FF
MOV     R2,#&20
MOV     R3,#&FF
SWI     "XOS_ReadLine"
MOVVS   PC,R14
MOV     R2,R1
MOV     R0,R5
MOV     R1,R12
MOV     R3,#0
MOV     R4,#0
SWI     "XOS_SetVarVal"
MOV     PC,R14

I hope that people find these useful and don't object too much to my posting
source code (all 450 bytes of it!).  

Share and enjoy!

Nicko
+-----------------------------------------------------------------------------+
| Nicko van Someren, nbvs@cl.cam.ac.uk, (44) 223 358707 or (44) 860 498903    |
|       "Go and buy an Aleph One ARM3 card and stop whining!!!"               |
+-----------------------------------------------------------------------------+