Ctl-Opt DftActGrp(*No); // Some older examples of the use of these APIs will include the // Binding Directory QC2LE. This was only needed prior to V6 // and so can safely be omitted (but won't do any harm if used). // Proto for cvthc // Parm 1: Result string consisting of pairs of hex charcaters // Parm 2: The input string to be converted to its hex equivalent // Parm 3: Length in nybles of input (i.e. 2 * actual input length) dcl-pr CharToHex ExtProc('cvthc'); hexResult Char(65534) Options(*VarSize); charInput Char(32767) Options(*VarSize); charNibbles Int(10) Value; End-Pr; // Proto for cvtch // Parm 1: Resulting character string // Parm 2: The hex input string to be converted to its char equivalent // Parm 3: Length in characters of input dcl-pr HexToChar ExtProc('cvtch'); charResult Char(32767) Options(*VarSize); hexInput Char(65534) Options(*VarSize); hexLength Int(10) Value; End-Pr; // More "literal" Proto for cvtch // Parm 1: Pointer to resulting character string // Parm 2: Pointer to hex input string to be converted // Parm 3: Length in characters of input dcl-pr cvtch ExtProc('cvtch'); charResult pointer value; hexInput pointer value; hexLength Int(10) Value; End-Pr; // Very large field that will be initiaized with hex pattern dcl-s bigHex char(16000000); // DS to hold result of converting bigHex // Last 50 charcaters are defined separatly for DSPLY purposes // so that we can demonstarte that the conversion worked dcl-ds bigChar len(8000000); dsplyChars char(50) pos(7999951); End-Ds; // Other working variables dcl-s textString char(24); dcl-s hexString char(48); dcl-s length int(10); dcl-s wait char(1); // Invite user input Dsply ('Enter Max 24 char string') ' ' textString; // Calculate the number of hex nibbles in field length = %Size(textString) * 2; // Convert string to hex pairs CharToHex ( hexString : textString : length ); // And proudly show off the response Dsply 'Hex result is:'; Dsply hexstring; // Now we reverse the process going Hex to char ... HexToChar ( textString : hexString : %Size(hexString)); // And show the result Dsply 'Converting back to char results in:'; Dsply textString; // Now we will use the pointer version for a very large field // First we initialize the field to the hex pattersn for '1234...0' bigHex = *All'F1F2F3F4F5F6F7F8F9F0'; // Now for the conversion cvtch ( %Addr(bigChar) : %Addr(bigHex) : %Size(bigHex) ); // And display the last part of the resulting string Dsply 'Result of big hex conversion is ...'; Dsply dsplyChars; Dsply 'Check results above and press enter when done' ' ' wait; *InLR = *On;