particular program, but others, such as PROCcircle, are more general-purpose.
You may like to use these procedures in programs of your own.
Functions
A function is a routine which takes one or more parameters and uses them to
calculate a result. BBC BASIC contains some built-in functions. Try:
PRINT LEN("Acorn Computers")
LEN is a function which takes a string as a parameter and produces the length
of the string as the result. Now try:
PRINT SQR(9)
SQR is a function taking a number as a parameter and producing its square
root as the result.
BBC BASIC allows you to set up your own functions, as this example shows:
10 MODE 135
20 PROCinput_t ime
30 END
40 DEFPROCinput_time
50 PRINT'"Input a time in minutes and seconds."
60 PRINT '"The function will convert it into"
70 PRINT"seconds. "
80 INPUT'"How many minutes and seconds ",minutes%,seconds%
90 total%=FNconvert (minutes%,seconds%)
100 PRINT' "That is " ; total%; " seconds. "
110 ENDPROC
120 DEFFNconvert(mins%,secs%)
130 =mins%*60+secs%
Line 90 calls the function. The computer scans the rest of the program until it
finds the DEFinition of the FuNction (DEFFN) at 120.
Line 130 begins with an equals sign. This tells the computer that the
calculation which follows will produce the required result, and that the function
ends on this line. The calculation is carried out, the function ends, and the
program returns to line 90 and stores the result in total%.
The function here is a trivial example, as it is simpler to just put:
90 total%=minutes%*60+seconds%
C 36