%CNV_PI

Convert portable integer data to native form

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
native = %CNV_PI(portable_int)

Return value

native

The converted data in native form. (i)

Arguments

portable_int

The portable integer field to convert. (a)

Discussion

%CNV_PI converts a portable integer created by a previous %CNV_IP intrinsic function back to native form. (See %CNV_IP.)

When you use the integer data type, your data files are not portable between big‑endian and little‑endian machines. (If you don’t know what endian type your machine is, see Endian types) Once you’ve used the %CNV_IP intrinsic function to convert your data to portable form and moved it to another machine, you can use %CNV_PI to convert your data back to native form.

Tip

For integer data in ISAM files on Windows and UNIX, we recommend using the portable integer specification, I=pos:len (or PORT_INT pos:len in XDL form).

Examples

The following routine reads a portable integer from a file and returns it as a native integer.

function rd_portable
    ch          ,n                      ;Open channel
    size        ,n                      ;Size of integer
record
    p_dat       ,a8                     ;Portable integer data
    int         ,i4
proc
    gets(ch, p_dat(1:size))             ;Read portable data from file
    int = %cnv_pi(p_dat(1:size))        ; convert back to integer
    freturn (int)                       ; and return it
endfunction