Change color on portion of 80 character field in certain conditions

35 pts.
Tags:
iSeries
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?
ASKED: January 26, 2010  7:34 PM
UPDATED: January 27, 2010  3:40 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Meandyou
    Change the color of the output on a screen? Something wrong with green letters on black background?
    5,220 pointsBadges:
    report
  • Canuhlp
    One of the options on the line is being built and the color difference quickly identifies it as such.
    35 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following