Home » Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_23.ADF » F/TUT3

F/TUT3

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 » Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_23.ADF
Filename: F/TUT3
Read OK:
File size: 112A bytes
Load address: 54204556
Exec address: D335455
File contents
Another new word in line 20 is TRUE. All computers work in 1s and
0s, yes or no, TRUE or FALSE. Here if a key has been pressed then INKEY
will have a value to put into the variable A and so INKEY will be TRUE,
If no key has been pressed then INKEY won't be true and the program can't
execute line 20.

OK so it's a little obscure. But you just have to learn it. The people who
wrote this did so before the first space rockets, come to think of it it
was before I was born. Be thankful it was Americans, if it had been
British then every word in computers would have been named after some
scientist, SMITH BLESSINGTON-SMYTH CARTER JONES$ A somehow doesn't roll so
well as IF TRUE PRINT CHR$ A

The CHR$ in line 20 will convert an ASCII number to its respective symbol.
Try typing in: PRINT CHR$ 101
Computers use numbers to represent each of the characters on the keyboard
and a few others besides. If line 20 had said PRINT A then the ASCII code
for the key you had pressed would have been printed. 

If after 10 seconds you don't press any key the program will put the value
-1 into the variable A. INKEY is then clearly false and so line 20 cannot
be executed. So the program will jump to line 30. 

This version of INKEY is interesting but it's uses are a little limited.

The other form of INKEY is much more useful.

This form is followed by a negative number. This number represents a
particular key on the keyboard. These are not the ASCII values though for
example A is represented by -66 while B is represented by -101.

Now the real advantage of this form of INKEY is that it can be written so
that a paticular action will occur when a certain key has been pressed.
Setting it up is quite easy provided you have access to a list of the key
codes. Also it doesn't matter if you press a capitol letter or a small
case. These are on page 159 of the Elk's user guide and page 275 of my
copy of the Beeb user guide.

10 PRINT" PRESS A"
20 REPEAT
30 IF INKEY(-66) PRINT"WELL DONE"     
40 UNTIL FALSE

This program will wait until you have pressed A or a and then print WELL
DONE. As it stands it will then continue untill you press A again and
print WELL DONE. Not very useful as it stands but the principal is.

Notice in lines 20 and 40 the words REPEAT and UNTIL FALSE. These take us
nicely to what is perhaps the most important facility on any computer, the
Loop.

In computing there are many times when you need a loop, the last program
told you to press A, and when you had done so to print WELL DONE otherwise
to continue waiting until you pressed A. The REPEAT UNTIL is a loop which
continually cycles through the part of the program between the REPEAT and
UNTIL trying to execute the lines between untill a condition is met, in
this case FALSE when the loop will be broken and the program will
continue.

Another loop is the FOR NEXT loop. This loop will count until a certain
figure is reached and then the loop is complete and the program continues.

10 FOR A = 1 TO 10
20 READ A$
30 PRINT"HAVE SOME TEA "A$
40 NEXT
50 DATA VICAR,TEACHER,MOTHER,FATHER,DOCTOR,REPAIRMAN,SISTER,BROTHER,DOG,
GOLDFISH

Here the loop will cycle 10 times, each time executing the lines between.
When A is equal to 10 the cycling will stop and the program will continue
or end.

Line 20 is a READ which will read information from a DATA line and place
it into the variable A$. In a DATA line each item is separated by a comma,
and there must be enough items for the size of the FOR NEXT loop in this
case 10. Though there can be more this can have some unusual effects if
another READ command is encountered later in the program.

Line 30 is a silly question where the person being spoken to is not
specified, instead there is an A$ after the closing " We used  this
before.

Line 40 is the NEXT command, it, tells the computer to cycle back to the
FOR command.

Finally the DATA line.

The FOR NEXT loop really comes into it's own when some sort of counting is
needed.

10 FOR A = 1 TO 255
20SOUND 1,-15,A,1
30NEXT

This short program when run will produce a rising tone. Line 10 makes the
variable A initially equal to 1. Line 20 is a SOUND command. The third
parameter which is the pitch of the sound is set to A, so for the first
pass this will be 1, quite a low pitch. Line 30 is the NEXT command which
causes the program to cycle back to the FOR in line 10 where A is now
equal to 2 and so on.
00000000  0d 41 6e 6f 74 68 65 72  20 6e 65 77 20 77 6f 72  |.Another new wor|
00000010  64 20 69 6e 20 6c 69 6e  65 20 32 30 20 69 73 20  |d in line 20 is |
00000020  54 52 55 45 2e 20 41 6c  6c 20 63 6f 6d 70 75 74  |TRUE. All comput|
00000030  65 72 73 20 77 6f 72 6b  20 69 6e 20 31 73 20 61  |ers work in 1s a|
00000040  6e 64 0d 30 73 2c 20 79  65 73 20 6f 72 20 6e 6f  |nd.0s, yes or no|
00000050  2c 20 54 52 55 45 20 6f  72 20 46 41 4c 53 45 2e  |, TRUE or FALSE.|
00000060  20 48 65 72 65 20 69 66  20 61 20 6b 65 79 20 68  | Here if a key h|
00000070  61 73 20 62 65 65 6e 20  70 72 65 73 73 65 64 20  |as been pressed |
00000080  74 68 65 6e 20 49 4e 4b  45 59 0d 77 69 6c 6c 20  |then INKEY.will |
00000090  68 61 76 65 20 61 20 76  61 6c 75 65 20 74 6f 20  |have a value to |
000000a0  70 75 74 20 69 6e 74 6f  20 74 68 65 20 76 61 72  |put into the var|
000000b0  69 61 62 6c 65 20 41 20  61 6e 64 20 73 6f 20 49  |iable A and so I|
000000c0  4e 4b 45 59 20 77 69 6c  6c 20 62 65 20 54 52 55  |NKEY will be TRU|
000000d0  45 2c 0d 49 66 20 6e 6f  20 6b 65 79 20 68 61 73  |E,.If no key has|
000000e0  20 62 65 65 6e 20 70 72  65 73 73 65 64 20 74 68  | been pressed th|
000000f0  65 6e 20 49 4e 4b 45 59  20 77 6f 6e 27 74 20 62  |en INKEY won't b|
00000100  65 20 74 72 75 65 20 61  6e 64 20 74 68 65 20 70  |e true and the p|
00000110  72 6f 67 72 61 6d 20 63  61 6e 27 74 0d 65 78 65  |rogram can't.exe|
00000120  63 75 74 65 20 6c 69 6e  65 20 32 30 2e 0d 0d 4f  |cute line 20...O|
00000130  4b 20 73 6f 20 69 74 27  73 20 61 20 6c 69 74 74  |K so it's a litt|
00000140  6c 65 20 6f 62 73 63 75  72 65 2e 20 42 75 74 20  |le obscure. But |
00000150  79 6f 75 20 6a 75 73 74  20 68 61 76 65 20 74 6f  |you just have to|
00000160  20 6c 65 61 72 6e 20 69  74 2e 20 54 68 65 20 70  | learn it. The p|
00000170  65 6f 70 6c 65 20 77 68  6f 0d 77 72 6f 74 65 20  |eople who.wrote |
00000180  74 68 69 73 20 64 69 64  20 73 6f 20 62 65 66 6f  |this did so befo|
00000190  72 65 20 74 68 65 20 66  69 72 73 74 20 73 70 61  |re the first spa|
000001a0  63 65 20 72 6f 63 6b 65  74 73 2c 20 63 6f 6d 65  |ce rockets, come|
000001b0  20 74 6f 20 74 68 69 6e  6b 20 6f 66 20 69 74 20  | to think of it |
000001c0  69 74 0d 77 61 73 20 62  65 66 6f 72 65 20 49 20  |it.was before I |
000001d0  77 61 73 20 62 6f 72 6e  2e 20 42 65 20 74 68 61  |was born. Be tha|
000001e0  6e 6b 66 75 6c 20 69 74  20 77 61 73 20 41 6d 65  |nkful it was Ame|
000001f0  72 69 63 61 6e 73 2c 20  69 66 20 69 74 20 68 61  |ricans, if it ha|
00000200  64 20 62 65 65 6e 0d 42  72 69 74 69 73 68 20 74  |d been.British t|
00000210  68 65 6e 20 65 76 65 72  79 20 77 6f 72 64 20 69  |hen every word i|
00000220  6e 20 63 6f 6d 70 75 74  65 72 73 20 77 6f 75 6c  |n computers woul|
00000230  64 20 68 61 76 65 20 62  65 65 6e 20 6e 61 6d 65  |d have been name|
00000240  64 20 61 66 74 65 72 20  73 6f 6d 65 0d 73 63 69  |d after some.sci|
00000250  65 6e 74 69 73 74 2c 20  53 4d 49 54 48 20 42 4c  |entist, SMITH BL|
00000260  45 53 53 49 4e 47 54 4f  4e 2d 53 4d 59 54 48 20  |ESSINGTON-SMYTH |
00000270  43 41 52 54 45 52 20 4a  4f 4e 45 53 24 20 41 20  |CARTER JONES$ A |
00000280  73 6f 6d 65 68 6f 77 20  64 6f 65 73 6e 27 74 20  |somehow doesn't |
00000290  72 6f 6c 6c 20 73 6f 0d  77 65 6c 6c 20 61 73 20  |roll so.well as |
000002a0  49 46 20 54 52 55 45 20  50 52 49 4e 54 20 43 48  |IF TRUE PRINT CH|
000002b0  52 24 20 41 0d 0d 54 68  65 20 43 48 52 24 20 69  |R$ A..The CHR$ i|
000002c0  6e 20 6c 69 6e 65 20 32  30 20 77 69 6c 6c 20 63  |n line 20 will c|
000002d0  6f 6e 76 65 72 74 20 61  6e 20 41 53 43 49 49 20  |onvert an ASCII |
000002e0  6e 75 6d 62 65 72 20 74  6f 20 69 74 73 20 72 65  |number to its re|
000002f0  73 70 65 63 74 69 76 65  20 73 79 6d 62 6f 6c 2e  |spective symbol.|
00000300  0d 54 72 79 20 74 79 70  69 6e 67 20 69 6e 3a 20  |.Try typing in: |
00000310  50 52 49 4e 54 20 43 48  52 24 20 31 30 31 0d 43  |PRINT CHR$ 101.C|
00000320  6f 6d 70 75 74 65 72 73  20 75 73 65 20 6e 75 6d  |omputers use num|
00000330  62 65 72 73 20 74 6f 20  72 65 70 72 65 73 65 6e  |bers to represen|
00000340  74 20 65 61 63 68 20 6f  66 20 74 68 65 20 63 68  |t each of the ch|
00000350  61 72 61 63 74 65 72 73  20 6f 6e 20 74 68 65 20  |aracters on the |
00000360  6b 65 79 62 6f 61 72 64  0d 61 6e 64 20 61 20 66  |keyboard.and a f|
00000370  65 77 20 6f 74 68 65 72  73 20 62 65 73 69 64 65  |ew others beside|
00000380  73 2e 20 49 66 20 6c 69  6e 65 20 32 30 20 68 61  |s. If line 20 ha|
00000390  64 20 73 61 69 64 20 50  52 49 4e 54 20 41 20 74  |d said PRINT A t|
000003a0  68 65 6e 20 74 68 65 20  41 53 43 49 49 20 63 6f  |hen the ASCII co|
000003b0  64 65 0d 66 6f 72 20 74  68 65 20 6b 65 79 20 79  |de.for the key y|
000003c0  6f 75 20 68 61 64 20 70  72 65 73 73 65 64 20 77  |ou had pressed w|
000003d0  6f 75 6c 64 20 68 61 76  65 20 62 65 65 6e 20 70  |ould have been p|
000003e0  72 69 6e 74 65 64 2e 20  0d 0d 49 66 20 61 66 74  |rinted. ..If aft|
000003f0  65 72 20 31 30 20 73 65  63 6f 6e 64 73 20 79 6f  |er 10 seconds yo|
00000400  75 20 64 6f 6e 27 74 20  70 72 65 73 73 20 61 6e  |u don't press an|
00000410  79 20 6b 65 79 20 74 68  65 20 70 72 6f 67 72 61  |y key the progra|
00000420  6d 20 77 69 6c 6c 20 70  75 74 20 74 68 65 20 76  |m will put the v|
00000430  61 6c 75 65 0d 2d 31 20  69 6e 74 6f 20 74 68 65  |alue.-1 into the|
00000440  20 76 61 72 69 61 62 6c  65 20 41 2e 20 49 4e 4b  | variable A. INK|
00000450  45 59 20 69 73 20 74 68  65 6e 20 63 6c 65 61 72  |EY is then clear|
00000460  6c 79 20 66 61 6c 73 65  20 61 6e 64 20 73 6f 20  |ly false and so |
00000470  6c 69 6e 65 20 32 30 20  63 61 6e 6e 6f 74 0d 62  |line 20 cannot.b|
00000480  65 20 65 78 65 63 75 74  65 64 2e 20 53 6f 20 74  |e executed. So t|
00000490  68 65 20 70 72 6f 67 72  61 6d 20 77 69 6c 6c 20  |he program will |
000004a0  6a 75 6d 70 20 74 6f 20  6c 69 6e 65 20 33 30 2e  |jump to line 30.|
000004b0  20 0d 0d 54 68 69 73 20  76 65 72 73 69 6f 6e 20  | ..This version |
000004c0  6f 66 20 49 4e 4b 45 59  20 69 73 20 69 6e 74 65  |of INKEY is inte|
000004d0  72 65 73 74 69 6e 67 20  62 75 74 20 69 74 27 73  |resting but it's|
000004e0  20 75 73 65 73 20 61 72  65 20 61 20 6c 69 74 74  | uses are a litt|
000004f0  6c 65 20 6c 69 6d 69 74  65 64 2e 0d 0d 54 68 65  |le limited...The|
00000500  20 6f 74 68 65 72 20 66  6f 72 6d 20 6f 66 20 49  | other form of I|
00000510  4e 4b 45 59 20 69 73 20  6d 75 63 68 20 6d 6f 72  |NKEY is much mor|
00000520  65 20 75 73 65 66 75 6c  2e 0d 0d 54 68 69 73 20  |e useful...This |
00000530  66 6f 72 6d 20 69 73 20  66 6f 6c 6c 6f 77 65 64  |form is followed|
00000540  20 62 79 20 61 20 6e 65  67 61 74 69 76 65 20 6e  | by a negative n|
00000550  75 6d 62 65 72 2e 20 54  68 69 73 20 6e 75 6d 62  |umber. This numb|
00000560  65 72 20 72 65 70 72 65  73 65 6e 74 73 20 61 0d  |er represents a.|
00000570  70 61 72 74 69 63 75 6c  61 72 20 6b 65 79 20 6f  |particular key o|
00000580  6e 20 74 68 65 20 6b 65  79 62 6f 61 72 64 2e 20  |n the keyboard. |
00000590  54 68 65 73 65 20 61 72  65 20 6e 6f 74 20 74 68  |These are not th|
000005a0  65 20 41 53 43 49 49 20  76 61 6c 75 65 73 20 74  |e ASCII values t|
000005b0  68 6f 75 67 68 20 66 6f  72 0d 65 78 61 6d 70 6c  |hough for.exampl|
000005c0  65 20 41 20 69 73 20 72  65 70 72 65 73 65 6e 74  |e A is represent|
000005d0  65 64 20 62 79 20 2d 36  36 20 77 68 69 6c 65 20  |ed by -66 while |
000005e0  42 20 69 73 20 72 65 70  72 65 73 65 6e 74 65 64  |B is represented|
000005f0  20 62 79 20 2d 31 30 31  2e 0d 0d 4e 6f 77 20 74  | by -101...Now t|
00000600  68 65 20 72 65 61 6c 20  61 64 76 61 6e 74 61 67  |he real advantag|
00000610  65 20 6f 66 20 74 68 69  73 20 66 6f 72 6d 20 6f  |e of this form o|
00000620  66 20 49 4e 4b 45 59 20  69 73 20 74 68 61 74 20  |f INKEY is that |
00000630  69 74 20 63 61 6e 20 62  65 20 77 72 69 74 74 65  |it can be writte|
00000640  6e 20 73 6f 0d 74 68 61  74 20 61 20 70 61 74 69  |n so.that a pati|
00000650  63 75 6c 61 72 20 61 63  74 69 6f 6e 20 77 69 6c  |cular action wil|
00000660  6c 20 6f 63 63 75 72 20  77 68 65 6e 20 61 20 63  |l occur when a c|
00000670  65 72 74 61 69 6e 20 6b  65 79 20 68 61 73 20 62  |ertain key has b|
00000680  65 65 6e 20 70 72 65 73  73 65 64 2e 0d 53 65 74  |een pressed..Set|
00000690  74 69 6e 67 20 69 74 20  75 70 20 69 73 20 71 75  |ting it up is qu|
000006a0  69 74 65 20 65 61 73 79  20 70 72 6f 76 69 64 65  |ite easy provide|
000006b0  64 20 79 6f 75 20 68 61  76 65 20 61 63 63 65 73  |d you have acces|
000006c0  73 20 74 6f 20 61 20 6c  69 73 74 20 6f 66 20 74  |s to a list of t|
000006d0  68 65 20 6b 65 79 0d 63  6f 64 65 73 2e 20 41 6c  |he key.codes. Al|
000006e0  73 6f 20 69 74 20 64 6f  65 73 6e 27 74 20 6d 61  |so it doesn't ma|
000006f0  74 74 65 72 20 69 66 20  79 6f 75 20 70 72 65 73  |tter if you pres|
00000700  73 20 61 20 63 61 70 69  74 6f 6c 20 6c 65 74 74  |s a capitol lett|
00000710  65 72 20 6f 72 20 61 20  73 6d 61 6c 6c 0d 63 61  |er or a small.ca|
00000720  73 65 2e 20 54 68 65 73  65 20 61 72 65 20 6f 6e  |se. These are on|
00000730  20 70 61 67 65 20 31 35  39 20 6f 66 20 74 68 65  | page 159 of the|
00000740  20 45 6c 6b 27 73 20 75  73 65 72 20 67 75 69 64  | Elk's user guid|
00000750  65 20 61 6e 64 20 70 61  67 65 20 32 37 35 20 6f  |e and page 275 o|
00000760  66 20 6d 79 0d 63 6f 70  79 20 6f 66 20 74 68 65  |f my.copy of the|
00000770  20 42 65 65 62 20 75 73  65 72 20 67 75 69 64 65  | Beeb user guide|
00000780  2e 0d 0d 31 30 20 50 52  49 4e 54 22 20 50 52 45  |...10 PRINT" PRE|
00000790  53 53 20 41 22 0d 32 30  20 52 45 50 45 41 54 0d  |SS A".20 REPEAT.|
000007a0  33 30 20 49 46 20 49 4e  4b 45 59 28 2d 36 36 29  |30 IF INKEY(-66)|
000007b0  20 50 52 49 4e 54 22 57  45 4c 4c 20 44 4f 4e 45  | PRINT"WELL DONE|
000007c0  22 20 20 20 20 20 0d 34  30 20 55 4e 54 49 4c 20  |"     .40 UNTIL |
000007d0  46 41 4c 53 45 0d 0d 54  68 69 73 20 70 72 6f 67  |FALSE..This prog|
000007e0  72 61 6d 20 77 69 6c 6c  20 77 61 69 74 20 75 6e  |ram will wait un|
000007f0  74 69 6c 20 79 6f 75 20  68 61 76 65 20 70 72 65  |til you have pre|
00000800  73 73 65 64 20 41 20 6f  72 20 61 20 61 6e 64 20  |ssed A or a and |
00000810  74 68 65 6e 20 70 72 69  6e 74 20 57 45 4c 4c 0d  |then print WELL.|
00000820  44 4f 4e 45 2e 20 41 73  20 69 74 20 73 74 61 6e  |DONE. As it stan|
00000830  64 73 20 69 74 20 77 69  6c 6c 20 74 68 65 6e 20  |ds it will then |
00000840  63 6f 6e 74 69 6e 75 65  20 75 6e 74 69 6c 6c 20  |continue untill |
00000850  79 6f 75 20 70 72 65 73  73 20 41 20 61 67 61 69  |you press A agai|
00000860  6e 20 61 6e 64 0d 70 72  69 6e 74 20 57 45 4c 4c  |n and.print WELL|
00000870  20 44 4f 4e 45 2e 20 4e  6f 74 20 76 65 72 79 20  | DONE. Not very |
00000880  75 73 65 66 75 6c 20 61  73 20 69 74 20 73 74 61  |useful as it sta|
00000890  6e 64 73 20 62 75 74 20  74 68 65 20 70 72 69 6e  |nds but the prin|
000008a0  63 69 70 61 6c 20 69 73  2e 0d 0d 4e 6f 74 69 63  |cipal is...Notic|
000008b0  65 20 69 6e 20 6c 69 6e  65 73 20 32 30 20 61 6e  |e in lines 20 an|
000008c0  64 20 34 30 20 74 68 65  20 77 6f 72 64 73 20 52  |d 40 the words R|
000008d0  45 50 45 41 54 20 61 6e  64 20 55 4e 54 49 4c 20  |EPEAT and UNTIL |
000008e0  46 41 4c 53 45 2e 20 54  68 65 73 65 20 74 61 6b  |FALSE. These tak|
000008f0  65 20 75 73 0d 6e 69 63  65 6c 79 20 74 6f 20 77  |e us.nicely to w|
00000900  68 61 74 20 69 73 20 70  65 72 68 61 70 73 20 74  |hat is perhaps t|
00000910  68 65 20 6d 6f 73 74 20  69 6d 70 6f 72 74 61 6e  |he most importan|
00000920  74 20 66 61 63 69 6c 69  74 79 20 6f 6e 20 61 6e  |t facility on an|
00000930  79 20 63 6f 6d 70 75 74  65 72 2c 20 74 68 65 0d  |y computer, the.|
00000940  4c 6f 6f 70 2e 0d 0d 49  6e 20 63 6f 6d 70 75 74  |Loop...In comput|
00000950  69 6e 67 20 74 68 65 72  65 20 61 72 65 20 6d 61  |ing there are ma|
00000960  6e 79 20 74 69 6d 65 73  20 77 68 65 6e 20 79 6f  |ny times when yo|
00000970  75 20 6e 65 65 64 20 61  20 6c 6f 6f 70 2c 20 74  |u need a loop, t|
00000980  68 65 20 6c 61 73 74 20  70 72 6f 67 72 61 6d 0d  |he last program.|
00000990  74 6f 6c 64 20 79 6f 75  20 74 6f 20 70 72 65 73  |told you to pres|
000009a0  73 20 41 2c 20 61 6e 64  20 77 68 65 6e 20 79 6f  |s A, and when yo|
000009b0  75 20 68 61 64 20 64 6f  6e 65 20 73 6f 20 74 6f  |u had done so to|
000009c0  20 70 72 69 6e 74 20 57  45 4c 4c 20 44 4f 4e 45  | print WELL DONE|
000009d0  20 6f 74 68 65 72 77 69  73 65 0d 74 6f 20 63 6f  | otherwise.to co|
000009e0  6e 74 69 6e 75 65 20 77  61 69 74 69 6e 67 20 75  |ntinue waiting u|
000009f0  6e 74 69 6c 20 79 6f 75  20 70 72 65 73 73 65 64  |ntil you pressed|
00000a00  20 41 2e 20 54 68 65 20  52 45 50 45 41 54 20 55  | A. The REPEAT U|
00000a10  4e 54 49 4c 20 69 73 20  61 20 6c 6f 6f 70 20 77  |NTIL is a loop w|
00000a20  68 69 63 68 0d 63 6f 6e  74 69 6e 75 61 6c 6c 79  |hich.continually|
00000a30  20 63 79 63 6c 65 73 20  74 68 72 6f 75 67 68 20  | cycles through |
00000a40  74 68 65 20 70 61 72 74  20 6f 66 20 74 68 65 20  |the part of the |
00000a50  70 72 6f 67 72 61 6d 20  62 65 74 77 65 65 6e 20  |program between |
00000a60  74 68 65 20 52 45 50 45  41 54 20 61 6e 64 0d 55  |the REPEAT and.U|
00000a70  4e 54 49 4c 20 74 72 79  69 6e 67 20 74 6f 20 65  |NTIL trying to e|
00000a80  78 65 63 75 74 65 20 74  68 65 20 6c 69 6e 65 73  |xecute the lines|
00000a90  20 62 65 74 77 65 65 6e  20 75 6e 74 69 6c 6c 20  | between untill |
00000aa0  61 20 63 6f 6e 64 69 74  69 6f 6e 20 69 73 20 6d  |a condition is m|
00000ab0  65 74 2c 20 69 6e 0d 74  68 69 73 20 63 61 73 65  |et, in.this case|
00000ac0  20 46 41 4c 53 45 20 77  68 65 6e 20 74 68 65 20  | FALSE when the |
00000ad0  6c 6f 6f 70 20 77 69 6c  6c 20 62 65 20 62 72 6f  |loop will be bro|
00000ae0  6b 65 6e 20 61 6e 64 20  74 68 65 20 70 72 6f 67  |ken and the prog|
00000af0  72 61 6d 20 77 69 6c 6c  0d 63 6f 6e 74 69 6e 75  |ram will.continu|
00000b00  65 2e 0d 0d 41 6e 6f 74  68 65 72 20 6c 6f 6f 70  |e...Another loop|
00000b10  20 69 73 20 74 68 65 20  46 4f 52 20 4e 45 58 54  | is the FOR NEXT|
00000b20  20 6c 6f 6f 70 2e 20 54  68 69 73 20 6c 6f 6f 70  | loop. This loop|
00000b30  20 77 69 6c 6c 20 63 6f  75 6e 74 20 75 6e 74 69  | will count unti|
00000b40  6c 20 61 20 63 65 72 74  61 69 6e 0d 66 69 67 75  |l a certain.figu|
00000b50  72 65 20 69 73 20 72 65  61 63 68 65 64 20 61 6e  |re is reached an|
00000b60  64 20 74 68 65 6e 20 74  68 65 20 6c 6f 6f 70 20  |d then the loop |
00000b70  69 73 20 63 6f 6d 70 6c  65 74 65 20 61 6e 64 20  |is complete and |
00000b80  74 68 65 20 70 72 6f 67  72 61 6d 20 63 6f 6e 74  |the program cont|
00000b90  69 6e 75 65 73 2e 0d 0d  31 30 20 46 4f 52 20 41  |inues...10 FOR A|
00000ba0  20 3d 20 31 20 54 4f 20  31 30 0d 32 30 20 52 45  | = 1 TO 10.20 RE|
00000bb0  41 44 20 41 24 0d 33 30  20 50 52 49 4e 54 22 48  |AD A$.30 PRINT"H|
00000bc0  41 56 45 20 53 4f 4d 45  20 54 45 41 20 22 41 24  |AVE SOME TEA "A$|
00000bd0  0d 34 30 20 4e 45 58 54  0d 35 30 20 44 41 54 41  |.40 NEXT.50 DATA|
00000be0  20 56 49 43 41 52 2c 54  45 41 43 48 45 52 2c 4d  | VICAR,TEACHER,M|
00000bf0  4f 54 48 45 52 2c 46 41  54 48 45 52 2c 44 4f 43  |OTHER,FATHER,DOC|
00000c00  54 4f 52 2c 52 45 50 41  49 52 4d 41 4e 2c 53 49  |TOR,REPAIRMAN,SI|
00000c10  53 54 45 52 2c 42 52 4f  54 48 45 52 2c 44 4f 47  |STER,BROTHER,DOG|
00000c20  2c 0d 47 4f 4c 44 46 49  53 48 0d 0d 48 65 72 65  |,.GOLDFISH..Here|
00000c30  20 74 68 65 20 6c 6f 6f  70 20 77 69 6c 6c 20 63  | the loop will c|
00000c40  79 63 6c 65 20 31 30 20  74 69 6d 65 73 2c 20 65  |ycle 10 times, e|
00000c50  61 63 68 20 74 69 6d 65  20 65 78 65 63 75 74 69  |ach time executi|
00000c60  6e 67 20 74 68 65 20 6c  69 6e 65 73 20 62 65 74  |ng the lines bet|
00000c70  77 65 65 6e 2e 0d 57 68  65 6e 20 41 20 69 73 20  |ween..When A is |
00000c80  65 71 75 61 6c 20 74 6f  20 31 30 20 74 68 65 20  |equal to 10 the |
00000c90  63 79 63 6c 69 6e 67 20  77 69 6c 6c 20 73 74 6f  |cycling will sto|
00000ca0  70 20 61 6e 64 20 74 68  65 20 70 72 6f 67 72 61  |p and the progra|
00000cb0  6d 20 77 69 6c 6c 20 63  6f 6e 74 69 6e 75 65 0d  |m will continue.|
00000cc0  6f 72 20 65 6e 64 2e 0d  0d 4c 69 6e 65 20 32 30  |or end...Line 20|
00000cd0  20 69 73 20 61 20 52 45  41 44 20 77 68 69 63 68  | is a READ which|
00000ce0  20 77 69 6c 6c 20 72 65  61 64 20 69 6e 66 6f 72  | will read infor|
00000cf0  6d 61 74 69 6f 6e 20 66  72 6f 6d 20 61 20 44 41  |mation from a DA|
00000d00  54 41 20 6c 69 6e 65 20  61 6e 64 20 70 6c 61 63  |TA line and plac|
00000d10  65 0d 69 74 20 69 6e 74  6f 20 74 68 65 20 76 61  |e.it into the va|
00000d20  72 69 61 62 6c 65 20 41  24 2e 20 49 6e 20 61 20  |riable A$. In a |
00000d30  44 41 54 41 20 6c 69 6e  65 20 65 61 63 68 20 69  |DATA line each i|
00000d40  74 65 6d 20 69 73 20 73  65 70 61 72 61 74 65 64  |tem is separated|
00000d50  20 62 79 20 61 20 63 6f  6d 6d 61 2c 0d 61 6e 64  | by a comma,.and|
00000d60  20 74 68 65 72 65 20 6d  75 73 74 20 62 65 20 65  | there must be e|
00000d70  6e 6f 75 67 68 20 69 74  65 6d 73 20 66 6f 72 20  |nough items for |
00000d80  74 68 65 20 73 69 7a 65  20 6f 66 20 74 68 65 20  |the size of the |
00000d90  46 4f 52 20 4e 45 58 54  20 6c 6f 6f 70 20 69 6e  |FOR NEXT loop in|
00000da0  20 74 68 69 73 0d 63 61  73 65 20 31 30 2e 20 54  | this.case 10. T|
00000db0  68 6f 75 67 68 20 74 68  65 72 65 20 63 61 6e 20  |hough there can |
00000dc0  62 65 20 6d 6f 72 65 20  74 68 69 73 20 63 61 6e  |be more this can|
00000dd0  20 68 61 76 65 20 73 6f  6d 65 20 75 6e 75 73 75  | have some unusu|
00000de0  61 6c 20 65 66 66 65 63  74 73 20 69 66 0d 61 6e  |al effects if.an|
00000df0  6f 74 68 65 72 20 52 45  41 44 20 63 6f 6d 6d 61  |other READ comma|
00000e00  6e 64 20 69 73 20 65 6e  63 6f 75 6e 74 65 72 65  |nd is encountere|
00000e10  64 20 6c 61 74 65 72 20  69 6e 20 74 68 65 20 70  |d later in the p|
00000e20  72 6f 67 72 61 6d 2e 0d  0d 4c 69 6e 65 20 33 30  |rogram...Line 30|
00000e30  20 69 73 20 61 20 73 69  6c 6c 79 20 71 75 65 73  | is a silly ques|
00000e40  74 69 6f 6e 20 77 68 65  72 65 20 74 68 65 20 70  |tion where the p|
00000e50  65 72 73 6f 6e 20 62 65  69 6e 67 20 73 70 6f 6b  |erson being spok|
00000e60  65 6e 20 74 6f 20 69 73  20 6e 6f 74 0d 73 70 65  |en to is not.spe|
00000e70  63 69 66 69 65 64 2c 20  69 6e 73 74 65 61 64 20  |cified, instead |
00000e80  74 68 65 72 65 20 69 73  20 61 6e 20 41 24 20 61  |there is an A$ a|
00000e90  66 74 65 72 20 74 68 65  20 63 6c 6f 73 69 6e 67  |fter the closing|
00000ea0  20 22 20 57 65 20 75 73  65 64 20 20 74 68 69 73  | " We used  this|
00000eb0  0d 62 65 66 6f 72 65 2e  0d 0d 4c 69 6e 65 20 34  |.before...Line 4|
00000ec0  30 20 69 73 20 74 68 65  20 4e 45 58 54 20 63 6f  |0 is the NEXT co|
00000ed0  6d 6d 61 6e 64 2c 20 69  74 2c 20 74 65 6c 6c 73  |mmand, it, tells|
00000ee0  20 74 68 65 20 63 6f 6d  70 75 74 65 72 20 74 6f  | the computer to|
00000ef0  20 63 79 63 6c 65 20 62  61 63 6b 20 74 6f 20 74  | cycle back to t|
00000f00  68 65 0d 46 4f 52 20 63  6f 6d 6d 61 6e 64 2e 0d  |he.FOR command..|
00000f10  0d 46 69 6e 61 6c 6c 79  20 74 68 65 20 44 41 54  |.Finally the DAT|
00000f20  41 20 6c 69 6e 65 2e 0d  0d 54 68 65 20 46 4f 52  |A line...The FOR|
00000f30  20 4e 45 58 54 20 6c 6f  6f 70 20 72 65 61 6c 6c  | NEXT loop reall|
00000f40  79 20 63 6f 6d 65 73 20  69 6e 74 6f 20 69 74 27  |y comes into it'|
00000f50  73 20 6f 77 6e 20 77 68  65 6e 20 73 6f 6d 65 20  |s own when some |
00000f60  73 6f 72 74 20 6f 66 20  63 6f 75 6e 74 69 6e 67  |sort of counting|
00000f70  20 69 73 0d 6e 65 65 64  65 64 2e 0d 0d 31 30 20  | is.needed...10 |
00000f80  46 4f 52 20 41 20 3d 20  31 20 54 4f 20 32 35 35  |FOR A = 1 TO 255|
00000f90  0d 32 30 53 4f 55 4e 44  20 31 2c 2d 31 35 2c 41  |.20SOUND 1,-15,A|
00000fa0  2c 31 0d 33 30 4e 45 58  54 0d 0d 54 68 69 73 20  |,1.30NEXT..This |
00000fb0  73 68 6f 72 74 20 70 72  6f 67 72 61 6d 20 77 68  |short program wh|
00000fc0  65 6e 20 72 75 6e 20 77  69 6c 6c 20 70 72 6f 64  |en run will prod|
00000fd0  75 63 65 20 61 20 72 69  73 69 6e 67 20 74 6f 6e  |uce a rising ton|
00000fe0  65 2e 20 4c 69 6e 65 20  31 30 20 6d 61 6b 65 73  |e. Line 10 makes|
00000ff0  20 74 68 65 0d 76 61 72  69 61 62 6c 65 20 41 20  | the.variable A |
00001000  69 6e 69 74 69 61 6c 6c  79 20 65 71 75 61 6c 20  |initially equal |
00001010  74 6f 20 31 2e 20 4c 69  6e 65 20 32 30 20 69 73  |to 1. Line 20 is|
00001020  20 61 20 53 4f 55 4e 44  20 63 6f 6d 6d 61 6e 64  | a SOUND command|
00001030  2e 20 54 68 65 20 74 68  69 72 64 0d 70 61 72 61  |. The third.para|
00001040  6d 65 74 65 72 20 77 68  69 63 68 20 69 73 20 74  |meter which is t|
00001050  68 65 20 70 69 74 63 68  20 6f 66 20 74 68 65 20  |he pitch of the |
00001060  73 6f 75 6e 64 20 69 73  20 73 65 74 20 74 6f 20  |sound is set to |
00001070  41 2c 20 73 6f 20 66 6f  72 20 74 68 65 20 66 69  |A, so for the fi|
00001080  72 73 74 0d 70 61 73 73  20 74 68 69 73 20 77 69  |rst.pass this wi|
00001090  6c 6c 20 62 65 20 31 2c  20 71 75 69 74 65 20 61  |ll be 1, quite a|
000010a0  20 6c 6f 77 20 70 69 74  63 68 2e 20 4c 69 6e 65  | low pitch. Line|
000010b0  20 33 30 20 69 73 20 74  68 65 20 4e 45 58 54 20  | 30 is the NEXT |
000010c0  63 6f 6d 6d 61 6e 64 20  77 68 69 63 68 0d 63 61  |command which.ca|
000010d0  75 73 65 73 20 74 68 65  20 70 72 6f 67 72 61 6d  |uses the program|
000010e0  20 74 6f 20 63 79 63 6c  65 20 62 61 63 6b 20 74  | to cycle back t|
000010f0  6f 20 74 68 65 20 46 4f  52 20 69 6e 20 6c 69 6e  |o the FOR in lin|
00001100  65 20 31 30 20 77 68 65  72 65 20 41 20 69 73 20  |e 10 where A is |
00001110  6e 6f 77 0d 65 71 75 61  6c 20 74 6f 20 32 20 61  |now.equal to 2 a|
00001120  6e 64 20 73 6f 20 6f 6e  2e 0d                    |nd so on..|
0000112a
F/TUT3.m0
F/TUT3.m1
F/TUT3.m2
F/TUT3.m4
F/TUT3.m5