Open topic with navigation
WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
string = %BIN(value[, magnitude])
The specified number as a string representation of binary characters, “0” or “1”. (a)
The value to convert to a binary character string. (n)
(optional) A value that determines the number of characters in the returned string: (n)
1 = 8-character string
2 = 16-character string
4 = 32-character string
8 = 64-character string
%BIN converts a decimal data value to a 32-bit longword value.
If magnitude is not present or if it contains a value other than 1, 2, 4, or 8, the resulting string is 32 characters long (if value can be represented in 32 bits) or 64 characters (if value cannot be represented in 32 bits).
The following example takes binary data from a record, stores it as byte flags, and displays the results.
subroutine show_cflags a_bit_flags ,n record group flags ,a unused_flg1 ,d1 ;Represents bit 0 unused_flg2 ,d1 unused_flg3 ,d1 unused_flg4 ,d1 public ,d1 domestic ,d1 less50 ,d1 vmail ,d1 ;Represents bit 7 endgroup proc flags = %bin(a_bit_flags, 1) if (public) writes(1, "Public company") if (domestic) writes(1, "Domestic sales") if (less50) writes(1, "Less than 50 employees") if (vmail) writes(1, "Voice mail system") xreturn endsubroutine