Data conversion – Functions in C

Prototypes of these functions are available in the:

  • ITR501.h file located for:
    • UNIX in the $RDJ_EXEC/exit directory
    • Windows in the%RDJ_EXEC%\exit directory
  • ITR501 file in the SRCLIB.H MVS library

For information on return values, refer to Return values

Convert from unsigned numeric to packed (SPK_Num2Pack)

Name Data Type Input / Output Description

szValNum

char

I

Value of the numeric data to be converted. This value must not contain the "+" sign
This field must be allocated in the calling program

nNbDecimale

int

I

Number of decimals if any
If this number is not null, a decimal point is expected in sValNum

sValPacke

char

O

Value of the data converted into packed format This field must be allocated in the calling program

Return value

 

 

  • Number of packed bytes
  • -1 if conversion fails

Convert from packed into numeric (SPK_Pack2Num)

Name Data Type Input / Output Description

sValPacke

char

I

Value of the packed data to be converted
This field must be allocated in the calling program

sLgPack

int

I

Size of the packed data in bytes

nLgRubDepack

int

I

Size of the expected numeric data in bytes

nNbDecimale

int

I

Number of decimals if any, in the expected numeric data
If this number is not null, a decimal point is generated in sValNum

szValNum

char

O

Request to check the data to be converted

Set this field to 1 to check that the data to be converted is packed

bCheck

int

I

Value of the data converted into numeric format This field must be allocated in the calling program

Its length must be equal to nLgRubDepack + 2
(1 character for the sign and one for \0)

Return value

 

 

  • 1: Conversion OK
  • 0: Packed type check fails

Convert from numeric to signed (SPK_Num2Sign)

Name Data Type Input / Output Description
szValNum char I Value of the numeric data to be converted: this value must not contain the "+" sign
This field must be allocated in the calling program
sValSignee char O Value of the data converted into the signed format
This field must be allocated in the calling program
Return value    
  • Length of the signed value if OK
  • -1 if conversion fails

Convert from signed into numeric (SPK_Sign2Num)

Name Data Type Input / Output Description
sValSignee char I Value of the signed data to be converted
This field must be allocated in the calling program
nLgSign int I Size of the data to be converted in bytes
szValNum char O

Request to check the data to be converted

Set this field to 1 to check that the data to be converted is signed

bCheck char O

Value of the data converted into numeric format.
This field must be allocated in the calling program

Its length must be equal to nLgRubDepack + 2 (1 character for the sign and one for \0)

Return value    
  • 1: Conversion OK
  • 0: If signed type check fails

Check a numeric value (SPK_IsSPKformat)

This function checks that a value is numeric (signed or decimal).

Name Data Type Input / Output Description

szVal

char

I

Value of the data to be checked
This field must be allocated in the calling program

nEntier

int

I

Data type:

  • 1: The data is an integer  (it contains no decimals)
  • 0: The data is not an integer (it contains decimals)

Return value

 

 

  • 1: Conversion OK
  • 0: check fails

Return values

The return values for the SPKxxx functions are:

  • -1:SPK_ERR_NUM2X
  • 0:SPK_ERR_X2NUM
    SPK_ERR_FORMAT
  • 1:SPK_OK

Related Links