OWBasic for Pocketviewer

Home INTRO Group CONTROL Alphabetical Index

Definition of user procedures

In OWBasic it is possible to define user procedures.
User procedures and functions must always be defined at the start of the program. The main program always begins after that.

A procedure definition begins with the procedure heading and ends with the keyword ENDP.

PROC test A, B#, VAR C
 <statements>
ENDP
The procedure heading begins with the keyword PROC, followed by the name of the procedure and the parameter list.
The parameter list describes the parameters of the procedure.
Variables used within the procedure are local, i.e., outside of the procedure they are unknown.

The call of user procedures takes place as with builtin procedures by means of the name. A user defined procedure is used, even if also a builtin procedure with the same name exists.
Example 1: Value parameter
PROC printxy x,y: ! Procedure that outputs coordinates 
 PRINT "("; x; ","; y; ")"; : ! Formatted output
ENDP

x=5: y=7: ! These variables do not have to do anything with 
          ! the procedure parameters.
printxy x-4, y+6: ! Example-Call
Example 2: Variables-Parameter
PROC myinc VAR n: ! Procedure similar to the builtin INC
 n=n+1
ENDP

i=4
myinc i : ! Example-Call
PRINT i : ! output is 5

Home INTRO Group CONTROL Alphabetical Index