You may try this:
(only essential code is shown)
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’)
%subst(W80:17:1) = Red; // change color
%subst(W80:26:1) = Normal; // back to normal (‘green’)
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..!).
<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.