Topic : The GFA-Basic Compendium
Author : GFA Systemtechnik GmbH
Version : GFABasic.HYP v2.98 (12/31/2023)
Subject : Documentation/Programming
Nodes : 899
Index Size : 28056
HCP-Version : 3
Compiled on : Atari
@charset : atarist
@lang :
@default : Document not found
@help : Help
@options : +g -i -s +z
@width : 75
@hostname : STRNGSRV
@hostname : CAB
@hostname : HIGHWIRE
@hostname : THING
View Ref-File[GOSUB|@]proc[(par1,par2,...)]
PROCEDURE proc[(var1,var2,...)]
(instructions)
RETURN
proc: procedure name
par1,par2: sexp,aexp
var1,var2: svar,avar
Between the commands PROCEDURE and RETURN are the instructions of a subroutine.
After PROCEDURE the name of the subroutine and possibly the list of the
variables to be received are placed. Calling a PROCEDURE takes place by giving
its name at the beginning of the line, along with a list of appropriate
parameters, which are placed in parentheses. For the sake of clarity, the
option of placing @ or GOSUB in front of the procedure name is available. This
also avoids the possibility of confusing procedure names with
commands, e.g. @rem, GOSUB stop. Parameters can be constants, variables, and
expressions. Not only the values, but also variables can be passed (see VAR).
The command RETURN is used to end a procedure. When it is reached during the
program execution, the program resumes execution from the instruction after the
GOSUB. In place of the command PROCEDURE one can write SUB and instead of
RETURN, ENDPROC, or ENDSUB can be used which the Interpreter replaces itself.
Example:
GOSUB slow_print("** Manual for **")
@slow_print("* GFA BASIC 3 *")
slow_print("GFA SYSTEMTECHNIK")
'
PROCEDURE slow_print(t$)
LOCAL i%
FOR i%=1 TO LEN(t$)
PRINT MID$(t$,i%,1);
PAUSE 3
NEXT i%
PRINT
RETURN
--> Slowly prints the message character by character.
a=8
@cube_root(a)
PRINT a
'
PROCEDURE cube_root(VAR x)
x=x^(1/3)
RETURN
--> Computes the cube root of 8 displaying 2 on the screen.