Home » Archimedes archive » Acorn User » AU 1994-04.adf » !BasicProg_BasicProg » Listing2

Listing2

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 User » AU 1994-04.adf » !BasicProg_BasicProg
Filename: Listing2
Read OK:
File size: 0190 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM >Listing2
   20:
   30ON ERROR REPORT:PRINT " at line ";ERL/10:END
   40MODE 0
   50INPUT "Please enter a word ";word$
   60num=0
   70PROCanagram("",word$)
   80PRINT "Number found ";num
   90END
  100:
  110DEF PROCanagram(c1$,s$)
  120LOCAL c2$,loop,rest$
  130CASE TRUE OF
  140 WHEN LEN(s$)>1
  150  FOR loop=1 TO LEN(s$)
  160   c2$=MID$(s$,loop,1)
  170   rest$=LEFT$(s$,loop-1)+MID$(s$,loop+1)
  180   PROCanagram(c1$+c2$,rest$)
  190  NEXT loop
  200 WHEN LEN(s$)=1
  210  PRINT c1$+s$
  220  num=num+1
  230ENDCASE
  240ENDPROC
� >Listing2
:
� � �:� " at line ";�/10:�
(� 0
2"� "Please enter a word ";word$
<	num=0
F�anagram("",word$)
P� "Number found ";num
Z�
d:
n� �anagram(c1$,s$)
x� c2$,loop,rest$
�
Ȏ � �
� � �(s$)>1
�  � loop=1 � �(s$)
�   c2$=�s$,loop,1)
�$   rest$=�s$,loop-1)+�s$,loop+1)
�   �anagram(c1$+c2$,rest$)
�  � loop
� � �(s$)=1
�  � c1$+s$
�  num=num+1
��
��
�
00000000  0d 00 0a 0f f4 20 3e 4c  69 73 74 69 6e 67 32 0d  |..... >Listing2.|
00000010  00 14 05 3a 0d 00 1e 1e  ee 20 85 20 f6 3a f1 20  |...:..... . .:. |
00000020  22 20 61 74 20 6c 69 6e  65 20 22 3b 9e 2f 31 30  |" at line ";./10|
00000030  3a e0 0d 00 28 07 eb 20  30 0d 00 32 22 e8 20 22  |:...(.. 0..2". "|
00000040  50 6c 65 61 73 65 20 65  6e 74 65 72 20 61 20 77  |Please enter a w|
00000050  6f 72 64 20 22 3b 77 6f  72 64 24 0d 00 3c 09 6e  |ord ";word$..<.n|
00000060  75 6d 3d 30 0d 00 46 16  f2 61 6e 61 67 72 61 6d  |um=0..F..anagram|
00000070  28 22 22 2c 77 6f 72 64  24 29 0d 00 50 19 f1 20  |("",word$)..P.. |
00000080  22 4e 75 6d 62 65 72 20  66 6f 75 6e 64 20 22 3b  |"Number found ";|
00000090  6e 75 6d 0d 00 5a 05 e0  0d 00 64 05 3a 0d 00 6e  |num..Z....d.:..n|
000000a0  16 dd 20 f2 61 6e 61 67  72 61 6d 28 63 31 24 2c  |.. .anagram(c1$,|
000000b0  73 24 29 0d 00 78 14 ea  20 63 32 24 2c 6c 6f 6f  |s$)..x.. c2$,loo|
000000c0  70 2c 72 65 73 74 24 0d  00 82 0a c8 8e 20 b9 20  |p,rest$...... . |
000000d0  ca 0d 00 8c 0e 20 c9 20  a9 28 73 24 29 3e 31 0d  |..... . .(s$)>1.|
000000e0  00 96 16 20 20 e3 20 6c  6f 6f 70 3d 31 20 b8 20  |...  . loop=1 . |
000000f0  a9 28 73 24 29 0d 00 a0  16 20 20 20 63 32 24 3d  |.(s$)....   c2$=|
00000100  c1 73 24 2c 6c 6f 6f 70  2c 31 29 0d 00 aa 24 20  |.s$,loop,1)...$ |
00000110  20 20 72 65 73 74 24 3d  c0 73 24 2c 6c 6f 6f 70  |  rest$=.s$,loop|
00000120  2d 31 29 2b c1 73 24 2c  6c 6f 6f 70 2b 31 29 0d  |-1)+.s$,loop+1).|
00000130  00 b4 1e 20 20 20 f2 61  6e 61 67 72 61 6d 28 63  |...   .anagram(c|
00000140  31 24 2b 63 32 24 2c 72  65 73 74 24 29 0d 00 be  |1$+c2$,rest$)...|
00000150  0c 20 20 ed 20 6c 6f 6f  70 0d 00 c8 0e 20 c9 20  |.  . loop.... . |
00000160  a9 28 73 24 29 3d 31 0d  00 d2 0e 20 20 f1 20 63  |.(s$)=1....  . c|
00000170  31 24 2b 73 24 0d 00 dc  0f 20 20 6e 75 6d 3d 6e  |1$+s$....  num=n|
00000180  75 6d 2b 31 0d 00 e6 05  cb 0d 00 f0 05 e1 0d ff  |um+1............|
00000190