%CNV_IP
Convert native integer data to portable form
WTSupported in traditional Synergy on Windows
|
WNSupported in Synergy .NET on Windows
|
USupported on UNIX
|
VSupported on OpenVMS
|
portable = %CNV_IP(native_int)
Return value
portable
The converted data in portable form. It is the same size as native_int. (a)
Arguments
native_int
The native-form integer field to convert. (i)
Discussion
%CNV_IP converts native-form integer data to portable form.
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.) You can use the %CNV_IP intrinsic function to convert your integer data to portable form, so it can be interpreted by Synergy DBL systems running on different machine architectures. For example, you might want to use %CNV_IP to maintain a file that must be accessed by machines with differing architectures over a network like NFS.
To convert your data back to native form, use %CNV_PI. Usually you will call %CNV_IP and %CNV_PI to convert integers directly within a data record before it is written out. By doing this, however, you must keep track of the data form (native or portable). Synergy DBL will not know the difference between a native integer and a portable integer.
Native_int is a native-form integer that’s the size of the integer being converted to portable, i.e., i2, i4, or i8. Do not use an expression for native_int.
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 writes an integer to a file in portable data format.
function wt_portable ch ,n ;Open channel int ,i ;Integer to convert and write to file size ,n ;Size of integer record p_dat ,a8 ;Portable integer data proc p_dat(1:size) = %cnv_ip(int) ;Convert integer to portable data puts(ch, p_dat(1:size)) ; and write to file freturn (0) endfunction