Open topic with navigation
WTSupported in traditional Synergy on Windows
USupported on UNIX
VSupported on OpenVMS
xcall BTOD(binary, decimal)
A field that contains the binary value to be converted. (a or n)
The variable that will be loaded with the destination of the converted binary value in decimal form. (d)
The BTOD subroutine, like its counterpart the DTOB subroutine, supports manipulation of binary bytes (8 bits), words (16 bits), and longwords (32 bits).
BTOD converts a binary value into the appropriate ASCII string in a decimal field, while DTOB does the converse. If the field overflows, no error occurs. If the binary source is larger than four bytes, the rightmost four bytes are treated as a four‑byte source. A one‑byte source field yields the same result as the DECML subroutine.
With the addition of the integer data type, the BTOD and DTOB routines are no longer required in dealing with native representation of binary data. We recommend you use the integer data type or the %ZONED function for greater efficiency.
If you define the following fields:
fld1 ,a1 fld2 ,a2 fld4 ,a4 fld5 ,a5
the statements below perform these results:
xcall dtob(-1, fld5) ;Yields %XFFFFFFFFFF in fld5 ; (equiv. to ^i(fld5)=-1)
xcall dtob(255, fld4) ;Yields %X000000FF in fld4
; (equiv. to ^i(fld4)=255) xcall btod(fld5, fld6) ;Yields fld6 = -1 ; (equiv. to ^d(fld6)=^i(fld5)) xcall btod(fld4, fld2) ;Yields fld2 = "255" ; (equiv. to ^d(fld2)=^i(fld4))