问题
I want to change the color of individual characters in a field in a subfile.
SCOTT LAWRENCE
JOHN SMITH
I like to show CO in SCOTT as RED color and MI in SMITH in RED color and all other character is GREEN. Can this be achieved ? I am having hard to finding a DSPATR at the individual character level instead of field level in the DSPF. Basically, I want to show characters in a field having values CO and MI in a subfile in a different color.
回答1:
The only way, in 5250 display to show CO in SCOTT as RED color would be to write hexadecimal value within your string, such as: 'S' + x'28' + 'CO' + x'20 + 'TT' (x28:red, x20:normal - cf. http://www.classanova.com/view?id=1382&p=5)
This will change the color but you will also have 1 space for any hexadecimal code: S CO TT
For GUI, you might have better alternatives. Maybe generating an HTML page with the color changes could an option.
回答2:
if your "NAME" field is a fixed length 10 characters, you'd make a data structure for each character...
DS 1 10 NAME
1 1 Name1
2 2 Name2 ... etc.
Then you'd load NAME with your input name SMITH. The name breaks down into individual fields. Use 10 display fields next to each other & define what color they would be. Load the screen fields with your DS fields SName1 = Name1 SName2 = Name2 Display the fields with colors you selected. SName1 SName2 SName3 .....
来源:https://stackoverflow.com/questions/28389175/as400-rpg-dspf-character-level-color-change