{{htmlmetatags>metatag-robots=()
metatag-title=(PROCEDURE...END PROC | ugBASIC User Manual)
metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum)
metatag-description=(Manual page for PROCEDURE...END PROC)
metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png)
metatag-og:title=(PROCEDURE...END PROC | ugBASIC User Manual)
metatag-og:description=(Manual page for PROCEDURE...END PROC)
}}
====== ugBASIC User Manual ======
===== PROCEDURE...END PROC ✓ =====
===== SYNTAX =====
PROCEDURE name[ par1[, par2[, ... ]]] ]
...
END PROC[ expression ]
==== PURPOSE ====
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''.
==== EXAMPLE ====
PROCEDURE test[ a, b ]
PRINT "HELLO WORLD! "; (a+b)
END PROC
PROCEDURE sumOf( x, y )
END PROC[x+y]
PROCEDURE hundred
END PROC[100]
See also the following example files:
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/procedures_hello_01.bas|procedures_hello_01.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/procedures_hello_02.bas|procedures_hello_02.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/procedures_hello_03.bas|procedures_hello_03.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/procedures_parameters_01.bas|procedures_parameters_01.bas]]''
* ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/procedures_parameters_02.bas|procedures_parameters_02.bas]]''
==== ABBREVIATION ====
PrcdEePrb
==== AVAILABLE ON ====
*
* Atari (400/800)
* Atari XL/XE
* Commodore 128 (MOS 8502)
* Commodore 128 (Zilog Z80)
* Commodore 64
* Commodore 64+REU
* TRS-80 Color Computer
* TRS-80 Color Computer 3
* ColecoVision
* Amstrad CPC 664
* Dragon 32
* Dragon 64
* Thomson MO5
* Thomson MO5
* Olivetti Prodest PC128
* Commodore PLUS/4
* SEGA SC-3000
* SEGA SG-1000
*
* VG-5000
* Commodore VIC-20
* ZX Spectrum 48
==== ANY PROBLEM? ====
If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=ISSUE ON PROCEDURE...END PROC|open an issue]] for this keyword on GitHub. Thank you!===== POWERED BY =====
[[:ugbasic:user:index|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]