In the article "Reduce Indicator Usage," Doug Eckersley shows how to use display attribute fields to control display files. I use those same attributes to spice up messages.
If you compile the following short program and call it from a command line, you'll see what I mean.
DCL VAR(&BLINK) TYPE(*CHAR) LEN(1) VALUE(X'28')
SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA(&BLINK +
*CAT 'By all means, PANIC NOW!') +
MSGTYPE(*ESCAPE)
When the program sends the escape message, you will see the words "By all means, PANIC NOW!" on the message line (usually line 24) of the display. If you call the program from a dumb terminal, the message will blink. On an enhanced system, which supports color, the message will appear in red. The reason for the unusual message appearance is that the first character of the message is hexadecimal 28, which is one of those display attribute fields Doug Eckersley wrote about.
You may use more than one display attribute in a message. In the following code fragment, written for a color monitor, parts of the message are shown in blue, white, and green.
DCL VAR(&WHITE) TYPE(*CHAR) LEN(1) VALUE(X'22')
DCL VAR(&GREEN) TYPE(*CHAR) LEN(1) VALUE(X'20')
SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA(&BLUE +
*CAT 'This is' *CAT &WHITE *CAT 'the' +
*CAT &GREEN *CAT 'msg') MSGTYPE(*ESCAPE)
To keep from having to specify a display attribute in CL programs, you can store display attributes in a message description instead. Whenever the message is displayed, the attribute will be applied. To see this in action, create a message file (or use one of your existing ones) and add a message to it.
ADDMSGD MSGID(XYZ0002) MSGF(MYMSGF) MSG(X'2E50F1') +
FMT((*CHAR 78))
The first character of the message is hexadecimal 2E, which stands for blinking, underscored, high-intensity text on a dumb terminal and red, blinking, underscored text on a color display. Hex 50F1 represents the character combination &1, which i5/OS and OS/400 recognize as a substitution expression in message descriptions. The value you specify in the MSGDTA (message data) parameter when you send the message will replace the &1 expression.
get excited!!!!!') MSGTYPE(*ESCAPE)
I developed these techniques after reading the tip "Display Status Messages in Reverse Image," which is on page 68 of the MC Press Desktop Encyclopedia of Tips, Techniques, and Programming Practices.
James Gates has spent most of the past 15 years working with AS/400 and iSeries systems.
LATEST COMMENTS
MC Press Online