我们可以用400提供的MI API函数CVTCH和CVTHC来实现字符和十六进制之间的互换。下面就是一个例子:
H DFTACTGRP(*NO) BNDDIR('QC2LE')
D cvtch PR ExtProc('cvtch')
D target 32767A options(*varsize)
D src_chars 65534A options(*varsize) const
D src_length 10I 0 value
D cvthc PR ExtProc('cvthc')
D target 65534A options(*varsize)
D src_bits 32767A options(*varsize) const
D tgt_length 10I 0 value
D buf S 25A
D hexdump S 50A
D wait s 1A
/free
// Create a "hex dump" of regular character data
buf = 'Hello';
cvthc( hexdump
: buf
: %len(%trimr(Buf)) * 2 );
dsply hexdump ' ' wait;
// Input the "hex dump" and convert to back to chars
buf = *blanks;
cvtch( buf
: hexdump
: %len(%trimr(hexdump)) );
dsply buf ' ' wait;
*inlr = *on;
/end-free
阅读(2478) | 评论(0) | 转发(1) |