Skip to content

FunctionsDeclaration

Régis Witz edited this page Nov 9, 2016 · 9 revisions

This pages describes how to:

  • declare functions

  • declare procedures

This page describes many rules regarding function or procedure declaration. All these rules begin with TCRFUN_.

Such rules are written with one of the following 2 formats:

  • RULE NAME
    Description of a rule which specification was validated.

  • RULE NAME
    Description of a rule which specification was not yet validated. It can thus change in the future: the rule can be renamed, it can be formulated differently, or it can be simply deleted (being replaced by other rules or just cancelled).

Declaration

Function declaration

TODO

Procedure declaration

TODO

Invocation

Function-only invocation

TODO

Procedure-only invocation

Procedure invocation syntax
CALL <procedure-name>
    <INPUT clause>?
    <INOUT clause>?
    <OUTPUT clause>?
END-CALL?
INPUT clause syntax
INPUT < <SENDING MODE clause>? <parameter-name> >+
SHARING MODE clause syntax
BY? <CONTENT | REFERENCE | VALUE>
INOUT clause syntax
INOUT <parameter-name>+
OUTPUT clause syntax
OUTPUT <parameter-name>+
  • TCRFUN_CALL_PARAMETER_ORDER
    During a procedure invocation, parameters are always used in the same order they are declared in the corresponding procedure:

    1. First, all INPUT parameters (if any)

    2. Second, all INOUT parameters (if any)

    3. Third, all OUTPUT parameters (if any)

  • TCRFUN_CALL_INPUT_BY
    INPUT parameters can be passed by content, by reference or by value. This distinction is made for a given parameter using the SHARING MODE clause. If the SHARING MODE clause is omitted, the corresponding parameter is passed by reference.

  • TCRFUN_CALL_INOUT_AND_OUTPUT_BY_REFERENCE
    INOUT,OUTPUT parameters are passed by reference. The SHARING MODE clause cannot be specified. In other words, BY REFERENCE is always implied for INOUT,OUTPUT parameters.

  • TCRFUN_MATCH_PARAMETERS_NUMBER
    The number of parameters provided on each procedure call must match the number of parameters of at least one declared procedure of the same name.

  • TCRFUN_MATCH_PARAMETERS_TYPE
    The type of all INPUT,INOUT,OUTPUT parameters provided on a given procedure call must match the type of all parameters of at least one declared procedure of the same name.

  • TCRFUN_MATCH_PARAMETERS_SIZE
    The logical size (without any concern about comp-*) of all INPUT,INOUT,OUTPUT parameters provided on a given procedure call must match the logical size of all parameters of at least one declared procedure of the same name.

  • TCRFUN_MATCH_PARAMETERS_COMPRESSION
    The physical compression of all INPUT,INOUT parameters provided on a given procedure call must match the physical compression (same comp-* between caller and callee) of all parameters of at least one declared procedure of the same name.

  • TCRFUN_EMPTY_CALL
    A CALL statement that has none of the USING, INPUT, INOUT, OUTPUT or RETURNING clauses is recognized as:

    • a procedure invocation if there is a procedure declared with no INPUT, INOUT or OUTPUT parameter visible in the current scope ;

    • a function invocation if there is a function declared with no INPUT or RETURNING parameter visible in the current scope ;

    • a standard COBOL CALL statement if there is neither.

Clone this wiki locally