Natural subprograms can be invoked from a programming object written in a
3rd generation programming language (3GL). The invoking program can be written
in any programming language that supports a standard CALL
interface.
For this purpose, Natural provides the interface
ncxr_callnat
. The 3GL program invokes this interface
with a specification of the name of the desired subprogram.
Note:
Natural must have been activated beforehand; that is, the invoking
3GL program must in turn have been invoked by a Natural object with a
CALL
statement.
The subprogram is executed as if it had been invoked from another Natural
object with a CALLNAT
statement.
When the processing of the subprogram stops (either with the
END
statement or with an
ESCAPE
ROUTINE
statement), control is returned to the 3GL
program.
This document covers the following topics:
Parameters can be passed from the invoking 3GL program to the Natural
subprogram. For passing parameters, the same rules apply as for passing
parameters with a CALL
statement.
The 3GL program invokes the Natural interface
ncxr_callnat
with four parameters:
The 1st parameter is the name of the Natural subprogram to be invoked.
The 2nd parameter contains the number of parameters to be passed to the subprogram.
The 3rd parameter contains the address of the table that contains the addresses of the parameters to be passed to the subprogram.
The 4th parameter contains the address of the table that contains the format/length specifications of the parameters to be passed to the subprogram.
The sequence, format and length of the parameters in the invoking
program must match exactly the sequence, format and length of the fields in the
DEFINE DATA
PARAMETER
statement of the subprogram. The names of the
fields in the invoking program and the invoked subprogram can be different.
For an example of how to invoke a Natural subprogram from a 3GL program, refer to the following samples in the Natural root directory's subdirectory samples\sysexuex.
MY3GL.NSP
(for the main program),
MY3GLSUB.NSN
(for the subprogram),
MYC3GL.C
(for the C
function).