7. Embedded QUEL for Pascal : Pascal Variables and Data Types : Compilation Units and the Scope of Objects : The Function
 
Share this page                  
The Function
The syntax for an EQUEL/Pascal function is:
function function_name [(formal_parameters)] : return_type_name
    [declarations]
begin
    [statements]
end;
Syntax Notes:
1. The function_name is not processed by EQUEL.
2. Formal parameters and variables declared in a function are visible to the function and to any nested blocks.
3. For a description of formal parameters and their syntax, see Formal Parameter Declarations.
4. EQUEL does not allow function calls to replace variables in executable statements. Therefore, EQUEL need not know the return_type_name.
The following is an example of a function:
##  function WasError( errorBuf : varying[ub] of 
##              Char ) : Boolean;
##  const
##           EquelNoError = 0;
##  var
##           errNum : Integer;
##  begin
##      INQUIRE_EQUEL (errNum = error)
        if errNum = EquelNoError then
        begin
        errorBuf := ' ';
            WasError := FALSE;
        end else
        begin
            SetErrorBuf( errNum, errorBuf );
            WasError := TRUE;
        end;
##  end;