Hi,
I'm busy with a utility program on the i-Series (written in OPM RPG - which is still the standard where I am) and I need to be able to show some fields in hex mode for editing, like the DSPPFM command when you press F10 and F11. So I'm looking to display the hex values "over and under", with the first hex digit on one line and the second hex digit on the line underneath. My question is : Is there an easy or neat way to do this, or do I have to translate everything from/to hex myself?
Thanks in advance,
Martin Gilbert.
Software/Hardware used:
ASKED:
April 15, 2008 2:10 PM
UPDATED:
April 16, 2008 11:59 AM
Hi Bruce,
I could call an external program, that shouldn’t be any problem. What did you have in mind?
Best regards,
Martin.
Hi Dan,
I wouldn’t call it lousy – a bit of a strange way of doing it, I would never have thought of it. I may just give this a try. Will have to see how it performs and will have to write the data to a file first (it’s coming from an MQ message queue).
Best regards,
Martin.
Here’s a little ILE CL program that will do the conversion:
PGM PARM(&DATA_IN &DATA_OUT &LEN_IN) DCL VAR(&DATA_IN) TYPE(*CHAR) LEN(1) DCL VAR(&DATA_OUT) TYPE(*CHAR) LEN(1) DCL VAR(&LEN_IN) TYPE(*INT) CALLPRC PRC('cvthc') PARM((&DATA_OUT) (&DATA_IN) + (&LEN_IN *BYVAL)) ENDPGMCreate it with:
CRTCLMOD MODULE(CHARTOHEX) DBGVIEW(*SOURCE)
CRTPGM PGM(CHARTOHEX) BNDDIR(QC2LE)
And call it from your OPM RPG program with three parameters:
1. The data you are starting from (the parameter can be any size X)
2. A receiver variable to get the converted data from (this variable must be defined twice the size as the first parameter – 2X)
3. A 4-byte binary value (9b 0) of 2X (ie – the size in bytes of the second parameter)
After you’ve called the program, if parameter 1 was ‘ABCDEF1234′ then parameter 2 will have the value ‘C1C2C3C4C5C6F1F2F3F4′. Loop through this taking the “odd” bytes and loading into your first line and the “even” bytes into the second display line.
Bruce Vining
Hi Bruce,
I will give this a try, sounds like just the thing I need. Can I do something similar to convert the hex back to character after editing? Do I need to call ‘cvtch’ for that?
Best regards,
Martin.
Hi, Martin
You got it. cvtch provides the reverse function of cvthc.
Bruce Vining
http://www.brucevining.com/
Providing integrated solutions for the System i user community
Hi Bruce,
Thanks for the help on this – it works a treat.
Best regards,
Martin Gilbert.