C Language Runtime Prototypes

A list of C language prototypes that are included with RPG xTools.

This is a list of a few of the C runtime library functions that have been prototyped for RPG IV use. You may call any of these procedures from your RPG IV programs. There are included in the RPG xTools in the CPROTOS source member in the QCPYSRC source file. For a complete list of the C functions that are included with the xTools, please see the CPROTOS source member.

RPG xTools C Language Prototypes

C Function Name "Called as"
RPG IV Prototype Name
Number of Parameters Description
system() RUNCMD or SYSTEM 1 Run a CL command
atoll() ATOLL 1 Convert character to numeric (no decimals, up to 20 digits)
atoi() ATOI 1 Convert character to numeric (no decimals, up to 10 digits)
itoa ITOA 3 Convert a number to a character string using a base value. Can be used to convert number to base 10, 2, 8, or 16.
sleep SLEEP 1 Performs a delay job ("sleep") operation.

system ( const char* CLCommandToRun )

The system function is used to run CL commands from within C or RPG IV modules. Only one parameter is needed, the CL command to run. Unlike QCMDEXC, no other parameters are required. This function is prototyped twice, once as its native name "system" and once as RUNCMD.

   callp         system('ADDLIBLE QGPL')

or

  callp         RunCmd('ADDLIBLE QGPL')

atoll( const char* Character-field-containing-numeric-value )

The atoll function converts a numeric string stored in a character field into a numeric value. The return value is a Int8 (20i0) value. This provides the same level of performance as the atoi() function except it handle much larger numeric values. Use atoll consistently to avoid potential problems with field lengths later on.

   eval        nPhoneNbr = atoll('  8005551212')

atoi( const char* Character-field-containing-numeric-value )

The atoi function converts a numeric string stored in a character field into a numeric value. The return value is a Int4 (10i0) value. This provides the same level of performance as the atoll() function except it handle much shorter numeric values. This function is fine for known value that will never exceed 10 digits (roughly 2 billion) but for larger numbers use atoll consistently to avoid potential problems with field lengths later on.

   eval        nModel = atoi('  3741')

 

XT_C_ERRMSGID - CPF Error Message ID for system function

The XT_cErrMsgID field is imported with the CPROTOS source member. It is a C language variable that contains the OS/400 CPF message ID when an error occurs when calling the system() function. Check the contents of this field for any errors that may occur.

C Function Prototypes  SRCMBR(CPROTOS) in XTOOLS/QCPYSRC

.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++
     D atoi            PR            10I 0 ExtProc('atoi')
     D  szCharIn                       *    Value Options(*String )
 
     D atoll           PR            20I 0 ExtProc('atoll')
     D  szCharIn                       *    Value Options(*String )
 
     D RunCmd          PR            10I 0 ExtProc( 'system' )
     D  szCmd                          *    Value Options( *String )
 
     D System          PR            10I 0 ExtProc( 'system' )
     D  szCmd                          *    Value Options( *String )
 
.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++
     D XT_C_ERRMSGID  S              7A  Import( '_EXCP_MSGID' )