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

203 ‘g’ is called a ‘formal parameter’ for the fuction FNST . It tells the computer that one number is going to be passed to the function when the function is used and inside the function we have decided to use the letter g to represent the variable. The procedure is ‘called’ or used like this – for example 230 PRINT "VAT inclusive price "; 236 PRINT FNST(P) and in this case ‘P’ is the ‘actual parameter’ for the function FNST . Whatever value ‘P’ has will be used inside the fuction wherever reference is made to teh formal parameter ‘g’. This is very convenient since you can use any variable names you like for the parameters inside the procedure.

Then you can call the procedure with a quite different set of parameter names from the outside. Very often a procedure will be called from many different places in the program – and the actual parameters may have different names each time the procedure or function is called. If a procedure or function is defined with (say) three formal parameters then, when it is called, three actual parameters must be supplied. See the fifth example below where three parameters are passed to the function. The end of the procedure is indicated with the statement ENDPROC . The end of a multi-line function is indicated by the statement that starts with an = sign.

The function is given the value of the expression to the right of the = sign. Examples First example – full program 210 REPEAT 220 INPUT "Basic price ",P 230 PRINT "VAT inclusive price "; 235 PRINT FNST(P) 240 UNTIL P=0 250 END 1000 REM line numeric function 1010 DEF FNST(g)=1.15*g Second example – program section Multi-line string function with one string parameter. 1000 DEF FNREVERSE(A$) 1010 REM reverse the order of the letters in A$ 1015 REM 1020 LOCAL d%,B$ 1030 FOR d%=1 TO LEN(A$)