COBOL Manual for TNS/E Programs (H06.03+)

Calling Other Programs and Routines
HP COBOL Manual for TNS/E Programs520347-003
23-25
Passing Parameters to Non-COBOL Routines
pTAL has a parameter type called string:length that is defined:
a^proc (a^string:length)
string .ext a^string
int length;
An HP COBOL program that calls a pTAL routine that has a string :length
parameter only passes one parameter, the string part. The compiler computes the
length of the string and passes it to the pTAL routine.
For example, suppose that your HP COBOL program calls the pTAL routine
FILE_GETINFOBYNAME_, which has the parameter file-name :maxlen. To
have your HP COBOL program pass the entire item, you can use this code:
01 A-FILENAME PIC X(20)
...
ENTER "FILE_GETINFOBYNAME_" USING A-FILENAME ...
To have your HP COBOL program pass part of the item, you can use either
reference modification or an OCCURS clause.
The code for reference modification is:
01 A-FILENAME PIC X(20)
...
MOVE 0 TO A-COUNT
INSPECT FUNCTION REVERSE (A-FILENAME) TALLYING A-COUNT
FOR LEADING SPACES
ENTER "FILE_GETINFOBYNAME_"
USING A-FILENAME
(1: FUNCTION LENGTH (A-FILENAME) - A-COUNT) ...
The code for using an OCCURS clause is:
01 A-FILENAME.
02 PIC X OCCURS 1 TO 20 TIMES DEPENDING ON
A-FILENAME-LENGTH.
01 A-FILENAME-LENGTH PIC 99 COMP.
Set A-FILENAME-LENGTH to the right length and call FILE_GETINFOBYNAME_
without using reference modification.
For more information about pTAL procedures, see the pTAL Reference Manual.