This couple of keywords create a procedure by giving it a name. The name is
then followed by a list of parameters and the procedure must be ended
with an END PROC
command. PROCEDURE
and END PROC
commands
should be placed on their own individual lines, but it is not mandatory.
Following the convention in other BASICs of the time, such as Simon's BASIC
or Tuned Simon's BASIC, the procedure name can also contain spaces. In this
case, the trailing space will not be considered as part of the name.
It is possible to place the procedure definition anywhere in the program.
When ugBASIC encounters a procedure statement, the procedure is recognised
and a jump is made to the final END PROC
. In this way, there is no
risk of executing your procedure by accident.
Following the procedure's name can be given a list of parameters. This creates a
group of local variables that can be loaded directly from the main program.
Note that the values to be loaded into parameters must be entered between
square brackets as part of the procedure call. This system works equally well
with constants as well as variables, but although you are allowed to
transfer integer, real or string variables, you may transfer also arrays
using this method. If you need to enter more than one parameter, the
variables must be separated by commas.
As an option, you can specify a value for the function to return.
The value must be indicated in square brackets ([...]
).
The value will then be copied into the PARAM
variable and
returned by the call, if the call was made in the context of an expression.
Important: if the OPTION CALL AS GOTO
pragma is in effect, the instruction
will be considered as a NOP
.
PROCEDURE name[ par1[, par2[, ... ]]] ] ... END PROC[ expression ]
Join BASIC 10Liner Contest with ugBASIC!
An interesting competition is held at the beginning of each year: the
BASIC 10Liner Contest.
It is possible to use ugBASIC to participate in the next
"BASIC10Liner" competition, in the following categories:
PROCEDURE...END PROC ↔ PrcdEePrb
If you have found a problem with this keyword, if you think there is a bug or, more
simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!
open an issue
BACK TO KEYWORDS