cobol CALL statement CALL statement


Example

COBOL can use static linkage for the following statement. GnuCOBOL uses dynamic linkage by default for all external symbols known at compile time, even when the symbol is a literal:

CALL "subprogram" USING a b c *> run a (possibly static linked) sub program
                              *> passing three fields

CALL some-prog USING a b c    *> some-prog is a PIC X item and can be changed
                              *> at run-time to do a dynamic lookup

This statement forces compile time link edit resolution. (Non standard, syntax extension):

CALL STATIC "subprogram" USING a b c

Fields in COBOL can be passed BY REFERENCE (the default, until overridden - overrides are sticky in a left to right order), BY CONTENT (a copy is passed BY REFERENCE), or in some cases directly BY VALUE:

CALL "calculation" USING BY REFERENCE a BY VALUE b BY CONTENT c RETURNING d
    ON EXCEPTION DISPLAY 'No linkage to "calculation"' UPON SYSERR
END-CALL 

COBOL is designed to be a BY REFERENCE language, so using BY VALUE can present issues. For instance, literal numerics have no explicit type and the COBOL spec has no explicit type promotion rules. Therefore developers have to worry about call frame setup with BY VALUE of literals.

See http://open-cobol.sourceforge.net/faq/index.html#call for more details.