HP 3000 Manuals

RPG/XL Enhancements [ COMMUNICATOR 3000/XL XL RELEASE 2.1 ] MPE/iX Communicators


COMMUNICATOR 3000/XL XL RELEASE 2.1

RPG/XL Enhancements 

by Rich Fengler 
Systems Technology Division 

RPG/XL (A.00.05) now supports the calling of intrinsics from RPG/XL
programs.

INTRINSIC CALLING FROM AN RPG/XL PROGRAM 

Two new Calculation Spec operators have been added to allow calling
intrinsics from RPG/XL programs.

The INTR operator is used to specify which intrinsic to call.  The INTR
operator is followed by the intrinsic name in Factor 2 through the Result
field (columns 33 through 48).  If the intrinsic is a function (returns a
value), a field in Factor 1 may be specified to hold the result.  If that
field has not previously been defined in the program, it can be defined
on the same line by specifying the length and decimal places in the
Result Field Length and Decimal Places fields (columns 49-51, and column
52).  The Resulting Indicators are set with the condition code, if
affected, on return from calling an intrinsic.  RPG programmers are
already accustomed to seeing these indicators set according to >, <, =
values.

The Calculation Spec operator IPARM is used to pass parameters to the
intrinsic.  RPG/XL will go through the Intrinsic Mechanism to determine
the right parameter type and call-by method to use.  Since RPG internally
stores all numeric fields in packed decimal format, RPG/XL will do the
necessary conversion before the call, and if passed by reference, also
after the call.

If a particular parameter in the parameter list may be defaulted, the
programmer may skip that parm by leaving the Result Field blank for that
IPARM operation.  RPG/XL will find out the default value from the
Intrinsic Mechanism and supply it for the call.

If the intrinsic is extensible (not all parameters are required), the
call can specify only the required parameters, leaving off a number of
parameters from the end of the list.  RPG/XL will communicate that
information to the intrinsic correctly.

The following are examples of an RPG/XL source segment using the
operators INTR and IPARM:

     C*  NUMCHR := ASCII (NUM, BASE, STR);
     C*  /* FUNCTION RETURN NUMCHR DEFINED AS NUMERIC,  */
     C*  /* 4 DIGITS, AND 0 DECIMAL PLACES.             */
     C*
     C           NUMCHR    INTR ASCII             40
     C                     IPARM          NUM
     C                     IPARM          BASE
     C                     IPARM          STR

     C*  WHO(,CAP);      /* SKIP THE FIRST PARAMETER */
     C*                  /* ALSO OPTION EXTENSIBLE.  */
     C*
     C                     INTR WHO
     C                     IPARM
     C                     IPARM          CAP

     C*  BIN := BINARY(ASCI, LEN);   /* ENABLE TESTING OF CONDITION CODE */
     C*
     C            BIN      INTR BINARY               010203
     C                     IPARM          ASCI
     C                     IPARM          LEN

This provides a basic intrinsic calling mechanism through RPG/XL.
However, it is recommended that users exercise extreme caution in using
this mechanism to call I/O intrinsics.  Mixing RPG cycle I/O with
user-driven Calculation Spec I/O may result in undesired input or output
operation.



MPE/iX Communicators