Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF (EN)

90 220 END 230 240 DEF PROCBOX(J) 250 MOVE -J,-J 260 DRAW -J,J 270 DRAW J,J 280 DRAW J,-J 290 DRAW -J,-J 300 ENDPROC The program uses a procedure called PROCBOX which draws a box. The size of the box is determined by the parameter J in the procedure. However you will see that in line 90 the procedure is called with the statement PROCBOX(X) . The initial value of X will be 510 because that is the starting value of the FOR loop at line 70. This value of X (510)will be passed to the parameter J in the procedure. As a result the procedure PROCBOX will draw a box of ‘size’ 5 10. J is called the ‘formal parameter’ for the procedure since it is used in the procedure itself.

However the X in line 90 and the K in line 150 are referred to as actual parameters. Whatever value K has in line 150 will be transferred to the formal parameter J. A procedure may have any number of parameters but there must be exactly the same number of actual parameters when the procedure is called as there are formal parameters in the procedure definition. Thus if a procedure was defined like this 1000 DEF PROCSWITCH(A,B,C$) 1040 ENDPROC it could not be called with a statement like 150 PROCSWITCH(X,Y) but this would be acceptable:

150 PROCSWITCH(length, height, NAME$) Local variables in procedures 10 J=25 20 FOR X=1 TO 5 30 PROCNUM (X) 40 PRINT "OUT OF PROCEDURE J= ";J 50 NEXT X 60 END 70 DEF PROCNUM(J)