function function_identifier: function_result_type; declaration_part begin statement_part end;
or with a parameter list:
function function_identifier (parameter_list): result_type; declaration_part begin statement_part end;
A function is a subroutine which has a return value of type function_result_type. It is structured like the program: the declaration_part consists of label, constant, type, variable or subroutine declarations in free order. The statement_part consists of a sequence of statements. If parameter_list is specified, parameters can be passed to the function and can be used in statement_part. The result is set via an assignment:
function_identifier := expression
Recursive function calls are allowed. Concerning the result type, ISO 7185 Pascal and Borland Pascal only allow the intrinsic types, subranges, enumerated types and pointer types to be returned. In Extended Pascal, function_result_type can be every assignable type. Of course, there are no type restrictions in GNU Pascal as well. If extended syntax is switched on, functions can be called like procedures via procedure call statement.
The Procedure, Subroutine Parameter List Declaration, Data Types