89 It all seems very straightforward and logical – and it is. Using procedures enables you to split a problem up into a number of small manageable sections and to use (or call) those sections with a sensible name. The main section of most programs should be just a number of procedure calls as are lines 90 to 140. The procedures themselves should be in a separate section – after the END statement. Let us examine PROCINTRO more closely. 160 DEF PROCINTRO 170 PRINT "This program tests your reactions" 180 PRINT 190 PRINT "Press the space bar to continue" 200 REPEAT UNTIL GET=32 210 CLS 220 ENDPROC Notice how it is defined:
line 160 is the start of the definition and the procedure ends at line 220; between those lines are normal BASIC statements. Lines 170, 180 and 190 just print messages on the screen. Line 200 waits until the space bar is pressed, after which line 210 clears the screen. There are a number of more complex things that can be done with procedures and another program will illustrate the use of parameters – variables passed to the procedure from the main program.
10 REM HYPNO 20 REM TIM DOBSON / ACORN COMPUTERS 30 REM VERSION 2 / 16 NOV 81 40 MODE 5 50 VDU29,640;512; 60 70 FOR X=510 TO 4 STEP -7 80 GCOL0,X 90 PROCBOX(X) 100 NEXT 110 120 REPEAT 130 GCOL RND(4),RND(4) 140 FOR K=0 TO 500 STEP 8 150 PROCBOX(K) 160 NEXT K 170 GCOL RND(4),RND(4) 180 FOR K=500 TO 0 STEP -9 190 PROCBOX(K) 200 NEXT K 210 UNTIL FALSE