Home » Archimedes archive » Acorn Computing » 1994 06.adf » 9406 » MsgTrans/Example

MsgTrans/Example

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn Computing » 1994 06.adf » 9406
Filename: MsgTrans/Example
Read OK:
File size: 059B bytes
Load address: 0000
Exec address: 0000
File contents
   10REM > Example
   20REM Program to demonstrate the use of the MessageTrans library
   30REM by Ben Summers
   40
   50REM Load library
   60LIBRARY "<Example$Dir>.MsgTranLib"
   70
   80REM init library
   90PROCmsgtrans_init("<Example$Dir>.Messages")
  100
  110
  120MODE 0
  130
  140REM tokens to look up
  150DATA "EG1","EG2","EG3","EG4","N","zonk",">>end<<"
  160
  170REM look up the tokens
  180
  190PRINT "****** Some simple tokens"
  200PRINT
  210READ token$
  220WHILE token$ <> ">>end<<"
  230
  240  PRINT "Token : "token$
  250  v$ = FNmsgtrans_lookup0(token$)
  260  PRINT "Value : "v$
  270  PRINT
  280
  290  READ token$
  300ENDWHILE
  310
  320
  330REM lookup up some more values, subsitiuting in some parameters
  340
  350param0$ = "Zero"
  360param1$ = "One"
  370param2  = 2.3563    : REM real number
  380param3  = 3         : REM interger
  390
  400PRINT "****** Now some tokens with substituted parameters"
  410PRINT
  420PRINT "Token : SUB1"
  430PRINT "Value : "FNmsgtrans_lookup1("SUB1", param0$)
  440PRINT
  450PRINT "Token : SUB2"
  460PRINT "Value : "FNmsgtrans_lookup2("SUB2", param0$, param1$)
  470PRINT
  480PRINT "Token : SUB3"
  490PRINT "Value : "FNmsgtrans_lookup3("SUB3", param0$, param1$, STR$(param2))
  500PRINT
  510PRINT "Token : SUB4"
  520PRINT "Value : "FNmsgtrans_lookup4("SUB4", param0$, param1$, STR$(param2), STR$(param3))
  530PRINT
  540
  550PRINT "****** Finally, look what happens if we lookup a token"
  560PRINT "       without providing enough parameters"
  570PRINT
  580PRINT "Token : SUB4  (but only one parameter"
  590PRINT "Value : "FNmsgtrans_lookup1("SUB4", param0$)
  600
  610
  620REM clear up afterwards
  630PROCmsgtrans_final
  640
  650END
  660

� > Example
@� Program to demonstrate the use of the MessageTrans library
� by Ben Summers
(
2� Load library
<!ț "<Example$Dir>.MsgTranLib"
F
P� init library
Z,�msgtrans_init("<Example$Dir>.Messages")
d
n
x� 0
�
�� tokens to look up
�2� "EG1","EG2","EG3","EG4","N","zonk",">>end<<"
�
�� look up the tokens
�
�!� "****** Some simple tokens"
��
�� token$
�ȕ token$ <> ">>end<<"
�
�  � "Token : "token$
�$  v$ = �msgtrans_lookup0(token$)
  � "Value : "v$
  �

"  � token$
,�
6
@
JA� lookup up some more values, subsitiuting in some parameters
T
^param0$ = "Zero"
hparam1$ = "One"
r'param2  = 2.3563    : � real number
|$param3  = 3         : � interger
�
�:� "****** Now some tokens with substituted parameters"
��
�� "Token : SUB1"
�2� "Value : "�msgtrans_lookup1("SUB1", param0$)
��
�� "Token : SUB2"
�;� "Value : "�msgtrans_lookup2("SUB2", param0$, param1$)
��
�� "Token : SUB3"
�F� "Value : "�msgtrans_lookup3("SUB3", param0$, param1$, �(param2))
��
�� "Token : SUB4"
Q� "Value : "�msgtrans_lookup4("SUB4", param0$, param1$, �(param2), �(param3))
�

&>� "****** Finally, look what happens if we lookup a token"
02� "       without providing enough parameters"
:�
D-� "Token : SUB4  (but only one parameter"
N2� "Value : "�msgtrans_lookup1("SUB4", param0$)
X
b
l� clear up afterwards
v�msgtrans_final
�
��
�
�
00000000  0d 00 0a 0f f4 20 3e 20  45 78 61 6d 70 6c 65 0d  |..... > Example.|
00000010  00 14 40 f4 20 50 72 6f  67 72 61 6d 20 74 6f 20  |..@. Program to |
00000020  64 65 6d 6f 6e 73 74 72  61 74 65 20 74 68 65 20  |demonstrate the |
00000030  75 73 65 20 6f 66 20 74  68 65 20 4d 65 73 73 61  |use of the Messa|
00000040  67 65 54 72 61 6e 73 20  6c 69 62 72 61 72 79 0d  |geTrans library.|
00000050  00 1e 14 f4 20 62 79 20  42 65 6e 20 53 75 6d 6d  |.... by Ben Summ|
00000060  65 72 73 0d 00 28 04 0d  00 32 12 f4 20 4c 6f 61  |ers..(...2.. Loa|
00000070  64 20 6c 69 62 72 61 72  79 0d 00 3c 21 c8 9b 20  |d library..<!.. |
00000080  22 3c 45 78 61 6d 70 6c  65 24 44 69 72 3e 2e 4d  |"<Example$Dir>.M|
00000090  73 67 54 72 61 6e 4c 69  62 22 0d 00 46 04 0d 00  |sgTranLib"..F...|
000000a0  50 12 f4 20 69 6e 69 74  20 6c 69 62 72 61 72 79  |P.. init library|
000000b0  0d 00 5a 2c f2 6d 73 67  74 72 61 6e 73 5f 69 6e  |..Z,.msgtrans_in|
000000c0  69 74 28 22 3c 45 78 61  6d 70 6c 65 24 44 69 72  |it("<Example$Dir|
000000d0  3e 2e 4d 65 73 73 61 67  65 73 22 29 0d 00 64 04  |>.Messages")..d.|
000000e0  0d 00 6e 04 0d 00 78 07  eb 20 30 0d 00 82 04 0d  |..n...x.. 0.....|
000000f0  00 8c 17 f4 20 74 6f 6b  65 6e 73 20 74 6f 20 6c  |.... tokens to l|
00000100  6f 6f 6b 20 75 70 0d 00  96 32 dc 20 22 45 47 31  |ook up...2. "EG1|
00000110  22 2c 22 45 47 32 22 2c  22 45 47 33 22 2c 22 45  |","EG2","EG3","E|
00000120  47 34 22 2c 22 4e 22 2c  22 7a 6f 6e 6b 22 2c 22  |G4","N","zonk","|
00000130  3e 3e 65 6e 64 3c 3c 22  0d 00 a0 04 0d 00 aa 18  |>>end<<"........|
00000140  f4 20 6c 6f 6f 6b 20 75  70 20 74 68 65 20 74 6f  |. look up the to|
00000150  6b 65 6e 73 0d 00 b4 04  0d 00 be 21 f1 20 22 2a  |kens.......!. "*|
00000160  2a 2a 2a 2a 2a 20 53 6f  6d 65 20 73 69 6d 70 6c  |***** Some simpl|
00000170  65 20 74 6f 6b 65 6e 73  22 0d 00 c8 05 f1 0d 00  |e tokens".......|
00000180  d2 0c f3 20 74 6f 6b 65  6e 24 0d 00 dc 1a c8 95  |... token$......|
00000190  20 74 6f 6b 65 6e 24 20  3c 3e 20 22 3e 3e 65 6e  | token$ <> ">>en|
000001a0  64 3c 3c 22 0d 00 e6 04  0d 00 f0 18 20 20 f1 20  |d<<"........  . |
000001b0  22 54 6f 6b 65 6e 20 3a  20 22 74 6f 6b 65 6e 24  |"Token : "token$|
000001c0  0d 00 fa 24 20 20 76 24  20 3d 20 a4 6d 73 67 74  |...$  v$ = .msgt|
000001d0  72 61 6e 73 5f 6c 6f 6f  6b 75 70 30 28 74 6f 6b  |rans_lookup0(tok|
000001e0  65 6e 24 29 0d 01 04 14  20 20 f1 20 22 56 61 6c  |en$)....  . "Val|
000001f0  75 65 20 3a 20 22 76 24  0d 01 0e 07 20 20 f1 0d  |ue : "v$....  ..|
00000200  01 18 04 0d 01 22 0e 20  20 f3 20 74 6f 6b 65 6e  |.....".  . token|
00000210  24 0d 01 2c 05 ce 0d 01  36 04 0d 01 40 04 0d 01  |$..,....6...@...|
00000220  4a 41 f4 20 6c 6f 6f 6b  75 70 20 75 70 20 73 6f  |JA. lookup up so|
00000230  6d 65 20 6d 6f 72 65 20  76 61 6c 75 65 73 2c 20  |me more values, |
00000240  73 75 62 73 69 74 69 75  74 69 6e 67 20 69 6e 20  |subsitiuting in |
00000250  73 6f 6d 65 20 70 61 72  61 6d 65 74 65 72 73 0d  |some parameters.|
00000260  01 54 04 0d 01 5e 14 70  61 72 61 6d 30 24 20 3d  |.T...^.param0$ =|
00000270  20 22 5a 65 72 6f 22 0d  01 68 13 70 61 72 61 6d  | "Zero"..h.param|
00000280  31 24 20 3d 20 22 4f 6e  65 22 0d 01 72 27 70 61  |1$ = "One"..r'pa|
00000290  72 61 6d 32 20 20 3d 20  32 2e 33 35 36 33 20 20  |ram2  = 2.3563  |
000002a0  20 20 3a 20 f4 20 72 65  61 6c 20 6e 75 6d 62 65  |  : . real numbe|
000002b0  72 0d 01 7c 24 70 61 72  61 6d 33 20 20 3d 20 33  |r..|$param3  = 3|
000002c0  20 20 20 20 20 20 20 20  20 3a 20 f4 20 69 6e 74  |         : . int|
000002d0  65 72 67 65 72 0d 01 86  04 0d 01 90 3a f1 20 22  |erger.......:. "|
000002e0  2a 2a 2a 2a 2a 2a 20 4e  6f 77 20 73 6f 6d 65 20  |****** Now some |
000002f0  74 6f 6b 65 6e 73 20 77  69 74 68 20 73 75 62 73  |tokens with subs|
00000300  74 69 74 75 74 65 64 20  70 61 72 61 6d 65 74 65  |tituted paramete|
00000310  72 73 22 0d 01 9a 05 f1  0d 01 a4 14 f1 20 22 54  |rs".......... "T|
00000320  6f 6b 65 6e 20 3a 20 53  55 42 31 22 0d 01 ae 32  |oken : SUB1"...2|
00000330  f1 20 22 56 61 6c 75 65  20 3a 20 22 a4 6d 73 67  |. "Value : ".msg|
00000340  74 72 61 6e 73 5f 6c 6f  6f 6b 75 70 31 28 22 53  |trans_lookup1("S|
00000350  55 42 31 22 2c 20 70 61  72 61 6d 30 24 29 0d 01  |UB1", param0$)..|
00000360  b8 05 f1 0d 01 c2 14 f1  20 22 54 6f 6b 65 6e 20  |........ "Token |
00000370  3a 20 53 55 42 32 22 0d  01 cc 3b f1 20 22 56 61  |: SUB2"...;. "Va|
00000380  6c 75 65 20 3a 20 22 a4  6d 73 67 74 72 61 6e 73  |lue : ".msgtrans|
00000390  5f 6c 6f 6f 6b 75 70 32  28 22 53 55 42 32 22 2c  |_lookup2("SUB2",|
000003a0  20 70 61 72 61 6d 30 24  2c 20 70 61 72 61 6d 31  | param0$, param1|
000003b0  24 29 0d 01 d6 05 f1 0d  01 e0 14 f1 20 22 54 6f  |$).......... "To|
000003c0  6b 65 6e 20 3a 20 53 55  42 33 22 0d 01 ea 46 f1  |ken : SUB3"...F.|
000003d0  20 22 56 61 6c 75 65 20  3a 20 22 a4 6d 73 67 74  | "Value : ".msgt|
000003e0  72 61 6e 73 5f 6c 6f 6f  6b 75 70 33 28 22 53 55  |rans_lookup3("SU|
000003f0  42 33 22 2c 20 70 61 72  61 6d 30 24 2c 20 70 61  |B3", param0$, pa|
00000400  72 61 6d 31 24 2c 20 c3  28 70 61 72 61 6d 32 29  |ram1$, .(param2)|
00000410  29 0d 01 f4 05 f1 0d 01  fe 14 f1 20 22 54 6f 6b  |).......... "Tok|
00000420  65 6e 20 3a 20 53 55 42  34 22 0d 02 08 51 f1 20  |en : SUB4"...Q. |
00000430  22 56 61 6c 75 65 20 3a  20 22 a4 6d 73 67 74 72  |"Value : ".msgtr|
00000440  61 6e 73 5f 6c 6f 6f 6b  75 70 34 28 22 53 55 42  |ans_lookup4("SUB|
00000450  34 22 2c 20 70 61 72 61  6d 30 24 2c 20 70 61 72  |4", param0$, par|
00000460  61 6d 31 24 2c 20 c3 28  70 61 72 61 6d 32 29 2c  |am1$, .(param2),|
00000470  20 c3 28 70 61 72 61 6d  33 29 29 0d 02 12 05 f1  | .(param3)).....|
00000480  0d 02 1c 04 0d 02 26 3e  f1 20 22 2a 2a 2a 2a 2a  |......&>. "*****|
00000490  2a 20 46 69 6e 61 6c 6c  79 2c 20 6c 6f 6f 6b 20  |* Finally, look |
000004a0  77 68 61 74 20 68 61 70  70 65 6e 73 20 69 66 20  |what happens if |
000004b0  77 65 20 6c 6f 6f 6b 75  70 20 61 20 74 6f 6b 65  |we lookup a toke|
000004c0  6e 22 0d 02 30 32 f1 20  22 20 20 20 20 20 20 20  |n"..02. "       |
000004d0  77 69 74 68 6f 75 74 20  70 72 6f 76 69 64 69 6e  |without providin|
000004e0  67 20 65 6e 6f 75 67 68  20 70 61 72 61 6d 65 74  |g enough paramet|
000004f0  65 72 73 22 0d 02 3a 05  f1 0d 02 44 2d f1 20 22  |ers"..:....D-. "|
00000500  54 6f 6b 65 6e 20 3a 20  53 55 42 34 20 20 28 62  |Token : SUB4  (b|
00000510  75 74 20 6f 6e 6c 79 20  6f 6e 65 20 70 61 72 61  |ut only one para|
00000520  6d 65 74 65 72 22 0d 02  4e 32 f1 20 22 56 61 6c  |meter"..N2. "Val|
00000530  75 65 20 3a 20 22 a4 6d  73 67 74 72 61 6e 73 5f  |ue : ".msgtrans_|
00000540  6c 6f 6f 6b 75 70 31 28  22 53 55 42 34 22 2c 20  |lookup1("SUB4", |
00000550  70 61 72 61 6d 30 24 29  0d 02 58 04 0d 02 62 04  |param0$)..X...b.|
00000560  0d 02 6c 19 f4 20 63 6c  65 61 72 20 75 70 20 61  |..l.. clear up a|
00000570  66 74 65 72 77 61 72 64  73 0d 02 76 13 f2 6d 73  |fterwards..v..ms|
00000580  67 74 72 61 6e 73 5f 66  69 6e 61 6c 0d 02 80 04  |gtrans_final....|
00000590  0d 02 8a 05 e0 0d 02 94  04 0d ff                 |...........|
0000059b