Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Color coding or Highlighting in RPG or CL Program

Status
Not open for further replies.

DinaMaqsud

Programmer
Oct 31, 2002
2
US
I need to find out how to highlight or color code a line in an RPG program or a CL. I understand that I need to use a hexidecimal character to do this, but I do not know how to put this in the program...Any ideas?

Thanks
 
DinaMaqsub
There are a couple of ways to do this. I have created a source member that contains lines with different colors that I simply cut and paste into different source members. And I also have a program that will change special characters to the hex values I want in a source member. It is possible to write a program that modifies a source member. A source physical file is a data file that contains three fields: SRCSEQ - sequence #; SRCDAT - date field; SRCDTA - data field (which contains the actual source code). You need to write a cl program with an override to the correct member, and a rpg program that will add the hex values.
Here are some hex values to use:

20 Green
24 Green w/underline
22 White
26 White underlined
28 Red
2C Red Underlined
38 Pink
3C Pink Underlined
3A Blue
3E Blue Underlined

I have a program but I have not modified it for RPGLE.
I also only colorize comment lines.
Here is a copy of the program, again it is written in RPG
for an RPG member. You will have to modify it for RPGLE as the rpg specifications have changed in RPGLE. I didn't have time to modify it, you will have to. this program uses special characters that will be translated into the hex values when you run it. this are documented in the program.

Code:
 *  Program Name:  COLORRPG                                            
 *   Description:  Colorize a Source Member (RPG/400 members)          
 *                                                                     
 * * * * * * * * * *  * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                                                     
 *     Color Code       Hex   Color                                    
 *     ----------       ---   ------------------------------------     
 *        `              20   Green                                    
 *        ~              22   White                                    
 *        !              28   Red                                      
 *        @              38   Pink                                     
 *        ¢              3A   Blue                                     
 *                                                                     
 *      Source Physical file:                                          
 *             1 - 6    Sequence Number                                
 *             7 - 12   Date of last Change                            
 *            13 - 92   80 Bytes of data  (normally)                   
 *               |    RPG source                                       
 *               ----  13 - 17  -  Pgm seq number                      
 *                     18 - 18  -  specification code (H,F,E,T,I,C,O)  
 *                     19 - 19  -  comment if '*'                       
 * ---------------------------------------------------------------      
FSOURCE  UF  F     256            DISK                                  
E                    SRC        73  1                                   
ISOURCE  AA  01                                                         
I                                       19  19 ASK                      
I                                       20  92 SRCE                     
I              '`~!@¢'               C         CODE                     
I              X'202228383A'         C         ATTR                     
I              X'20'                 C         GRN                      
 *                                                                      
C                     MOVE *BLANKS   BLANK6  6        dfn blnk fld      
 * Read a record                                                        
C                     READ SOURCE                   51 read rec         
 * Start Main Do while loop                                             
C           *IN51     DOWEQ*OFF                       Dow *in51 off     
C                     ADD  1         RECS              incr rec cntr    
C                     MOVE *OFF      COLOR   1         reset color flag 
 * Only colorize commented lines                                        
C           ASK       IFEQ '*'                         If comment       
C           CODE:1    SCAN SRCE:1    Y              61  find color code 
C           *IN61     IFEQ *ON                         If found        
C                     MOVE *ON       COLOR              set color flag 
C                     ENDIF                            Endif(found)    
 * xlate special characters to hex                                     
C           CODE:ATTR XLATESRCE      SRC1   73                         
C                     MOVEASRC1      SRC                               
 * check if color was turned on                                        
 * If yes, then reset color to green                                   
C           COLOR     IFEQ *ON                        If color on      
C                     MOVE GRN       SRC,73            set color green 
C                     ENDIF                           Endif(color on)  
 * update record                                                       
C                     EXCPTUPDATE                      Update recd     
C                     ENDIF                           Endif(comment)   
C                     READ SOURCE                   51 read record     
C                     ENDDO                           Enddo(*in51)     
 * End of program                                                      
C                     MOVE *ON       *INLR             End pgm         
C                     RETRN                            Return          
OSOURCE  E                UPDATE                                       
O                         BLANK6    12                                 
O                         SRC       92




 
Thanks for the information. Is there a way to do this outside of an RPG program?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top