35 pts.
 Change color on portion of 80 character field in certain conditions
In my qddssrc file I have an 80 character field that I move different literals to depending on certain conditions. In one case I want to be able to change positions 17 thru 26 of the 80 character literal to a different color than the rest of the line. Do any keywords exist to do this?

Software/Hardware used:
ASKED: January 26, 2010  7:34 PM
UPDATED: January 27, 2010  3:40 PM

Answer Wiki:
hi Canuhlp, You may try this: (only essential code is shown) <pre> D W80 s D Red C Const(x'28') D Normal C Const(x'20') D Protect C Const(x'80') D ColSep C Const(x'10') D Blink C Const(x'08') D Underline C Const(x'04') D Hi C Const(x'02') D Reverse C Const(x'01') D NonDisplay C Const(x'07') c/free %subst(W80:17:1) = Red; // change color %subst(W80:26:1) = Normal; // back to normal ('green') </pre> As you can see from the above code, a change in display-attribute 'steals' one character of your field. I cannot just now find the remaining hex-codes for coloring, but I mean to remember that they are in the range of 21 to 29 (approx..!). hppy testing ==================================================== <i>...change positions 17 thru 26 of the 80 character literal to a different color...</i> In that specific case, assuming that you want those positions to be 'Blue' while the rest of the characters are 'Green', you put x'3A' in position 16 of your field to turn Blue on for the next characters and x'20' in position 27 to revert back to normal Green for the remaining characters. Here's a <a href="http://www.rpgiv.com/dspatr.html">table to help you experiment</a> with colors. If you need different parts of the field to change colors for different display records, you place the appropriate hex character in the position just before the first character that you want to change and put x'20' just after the last character. Note that you use x'20' if you only want to revert back to 'normal'. Note that this means you'll want to have blanks in both of the character positions and that you won't be able to change the position before position 1 of your field nor after the last position of your field. If you need the color change to begin in position 1, then you need to change the field's COLOR() attribute. And if you want the change to extend through the last position of the field, you can ignore it since there is already an appropriate hex value in the position anyway. Some slightly finer control can be obtained by coding with the DSM APIs instead of using display files, but you need workstation devices or emulators that support 5250 Extended Attributes. Tom
Last Wiki Answer Submitted:  January 27, 2010  12:40 am  by  DanTheDane   2,540 pts.
All Answer Wiki Contributors:  DanTheDane   2,540 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Change the color of the output on a screen? Something wrong with green letters on black background?

 5,205 pts.

 

One of the options on the line is being built and the color difference quickly identifies it as such.

 35 pts.