You are here: start » ppl » statements » procedure

PROCEDURE

PROCEDURE

      [DECLARE] PROCEDURE proc( [TYPE var1 [VAR] ],...)

The keyword PROCEDURE is used in conjonction with the keyword DECLARE in the declaration of a user-defined procedure…
The optionnal VAR keyword tells PPL to copy the contents of the local variable back into the original variable when the procedure is finished processing.
The compiler directive “;$USEFUNCS” may be used in order to allow your main code (code between BEGIN & END) to be located anywhere within your file…
Example:

	;$USEFUNCS
	DECLARE PROCEDURE proc1(INTEGER i, STRING str, VAR INTEGER j)
	INTEGER int1,int2
	STRING s1
	BEGIN
	int1 = 1
	int2 = 2
	s1 = "HELLO"
	proc1(int1,s1,int2)
	PRINTLN "int1 =",int1
	PRINTLN "int2 =",int2
	PRINTLN "s1 =",s1
	END
	PROCEDURE proc1(INTEGER i,STRING str, VAR INTEGER j)
		PRINTLN "I'm in proc1"
		LET i = 30
		LET j = 15
	ENDPROC

See also: Function

ppl/statements/procedure.txt · Last modified: 2019/04/16 14:00
CC Attribution 4.0 International Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution 4.0 International