COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-65
ENTER
Restrictions on Calling TAL or pTAL Routines
If your HP COBOL program calls a TAL or pTAL routine that has a
string:length parameter, you only need to give the name of the corresponding
actual parameter, because the compiler can determine its length.
If a TAL or pTAL routine that has a string:length parameter does not ignore
trailing spaces and you want to pass it an actual parameter that is shorter than the
one defined for the corresponding formal parameter, use reference modification.
The HP COBOL code in Example 9-16 calls the pTAL routine
FILENAME_COMPARE_, which does not ignore trailing spaces and has two formal
parameters, filename1:length1 and filename2:length2.
If a TAL routine expects FORTRAN CHARACTER parameters (as the SMU
routines do), omit language when calling the routine. If you specify the
language TAL, differences in the TAL and FORTRAN parameter-passing
protocols will cause trouble.
The TAL parameter-passing protocol (which applies to all ordinary TAL routines
including operating system externals) is to push parameter addresses onto the
data stack and then call the routine.
The FORTRAN parameter-passing protocol is to push the length of each
CHARACTER parameter onto the data stack followed by its address. This allows
the called routine to retrieve the parameter’s length. If the called routine expects
lengths on the stack and they are not there, the called routine does not work as
intended.
In Example 9-17, a TNS HP COBOL program calls a TAL routine named
SYS^PROCEDURE that expects one reference parameter and three value
parameters. Because no qualifying mnemonic-name is present, one or more
search lists must be present (produced from SEARCH, LIBRARY, or CONSULT
directives) or the procedure must be in the object file COBOLEXT.
Example 9-16. Calling a pTAL Routine That Does Not Ignore Trailing Spaces
01 file-name-1 PIC X(255).
01 file-name-2 PIC X(255).
01 len-1 PIC 999 COMP.
01 len-2 PIC 999 COMP.
...
MOVE 0 TO len-1, len-2
INSPECT file-name-1 TALLYING len-1
FOR CHARACTERS BEFORE SPACE
INSPECT file-name-2 TALLYING len-2
FOR CHARACTERS BEFORE SPACE
ENTER "FILENAME_COMPARE_" USING file-name-1 (1: len-1)
file-name-2 (1: len-2)
GIVING ...