Using Hex colors to give LANSA fields color

Date: Archived
Product/Release: LANSA for the AS/400
Abstract: It is possible in LANSA for the AS/400 to use hex codes to give the value of fields specific colors
Submitted By: LANSA Technical Support

Values in fields can be given specific colors in LANSA for the AS/400. There are, of course, color attributes in LANSA, but using hex colors makes it possible to change the color at any time.

This works for LANSA for the AS/400 only, not LANSA for Windows.

This feature is particularly useful for such things as fields in a browselist. It may be required, for example, to display the value in a field in one color if it is a negative number, and another color if it is a positive number.

Below is sample RDML for putting entries in a browselist and displaying the values in red if they are less than zero, and blue if they are greater than zero :

* ********* Beginning of RDML commands **********           
FUNCTION   OPTIONS(*DIRECT *NOMESSAGES *DEFERWRITE)        
* *********                                                    
DEFINE     FIELD(#FIELD) TYPE(*DEC) LENGTH(5) DECIMALS(0)     
DEFINE     FIELD(#ALPHA) TYPE(*CHAR) LENGTH(6)                
DEFINE     FIELD(#HEXRED) TYPE(*CHAR) LENGTH(5)               
CHANGE     FIELD(#HEXRED) TO(X'28')                           
DEFINE     FIELD(#HEXBLUE) TYPE(*CHAR) LENGTH(5)              
CHANGE     FIELD(#HEXBLUE) TO(X'34')                          
DEF_LIST   NAME(#LIST) FIELDS((#ALPHA *OUT))                  
* *********                                                    
BEGIN_LOOP                                                    
REQUEST    FIELDS((#FIELD)) BROWSELIST(#LIST)                 
SUBSTRING  FIELD(#FIELD) INTO_FIELD(#ALPHA)                   
IF         COND('#FIELD <0')                                  
* ********* give field the color red:                          
use builtin(tconcat) with_args(#hexred #alpha) to_get(#alpha) 
else                                                          
* ********* give field the color blue:                         
use builtin(tconcat) with_args(#hexblue #alpha) to_get(#alpha)
endif                                                         
add_entry to_list(#list)                                      
end_loop                                                      
* ********* End of RDML commands **********

The following table contains hex codes and the colors they represent:

Hex code Color
X'20' green
X'21' green/reverse image
X'22' white
X'23' white/reverse image
X'24' green/underlined
X'25' green/reverse image/underlined
X'26' white/underlined
X'27' black
X'28' red
X'29' red/reverse image
X'2A red/blinking
X'2B' red/blinking/reverse image
X'2C' red/underlined
X'2D' red/underlined/reverse image
X'2E' red/blinking/underlined
X'30' turquoise/underlined with dots
X'31' turquoise/reverse image/underlined with dots
X'32' yellow/underlined with dots
X'33' yellow/reverse image/underlined with dots
X'34' bleu/underlined
X'35' bleu/reverse image
X'36' yellow/underlined
X'37' black/underlined
X'38' pink
X'39' pink/reverse image
X'3A' blue
X'3B' blue/reverse image
X'3C' pink/underlined
X'3D' pink/underlined/reverse image
X'3E' bleu underlined