Introduction to Functions and Procedures
Functions are algorithms that can be called to execute an already written set of code, and return a value to where they were called. They use the keywords FUNCTION, RETURNS, ENDFUNCTION. Functions can be used either with or without parameters.
Alternatively, with parameters:
The keyword RETURN is used to specify a value to be returned within the function. Upon encountering a RETURN statement, it is executed immediately, and any lines after the statement are ignored.
Procedures are similar to functions, however they do not return any value. They use the keywords PROCEDURE, ENDPROCEDURE. Procedures can also be used with or without parameters.
With parameters:
Procedures must be called using the CALL keyword, used respectively as follows:
An example of procedure definition and calling: