FUNCTION <functionidentifier>() RETURNS <datatype>
<some algorithm>
RETURN <some value>
ENDPROCEDURE
14.04
Parameters from the main program can be passed to the function. When they are passed they become known as arguments, once they are retrieved into the function they are then parameters within the function. It is good practice to limit access to data by using local variables where possible (python all variables are local). Where the parameters are passed into the function, this is known as the interface as one part of the program interfaces with another (think of program structure data flow diagram).
14.05 + 14.06
FUNCTION <functionidentifier>(<parameter list>) RETURNS <datatype>
<some algorithm>
RETURN <some value>
ENDPROCEDURE
Parameters are either passed by reference to the actual variable memory location, or as a copy of the variable's value. Python doesnt work in this way. For pseudocode then we must specify how the parameter is being passed:
FUNCTION <functionidentifier>(<BY REF <identifier: DATATYPE>) RETURNS <datatype>
<some algorithm>
RETURN <some value>
ENDPROCEDURE
or:
FUNCTION <functionidentifier>(<BY VAL <identifier: DATATYPE>) RETURNS <datatype>
<some algorithm>
RETURN <some value>
ENDPROCEDURE
The pseudocode statement to call a procedure:
CALL <functionidentifier>(parameters by value or reference)