TechTip: Same Screen, New Colors

SQL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times
There are many ways to make iSeries and AS/400 screens look friendlier to users: pull-down menus, menu bars, scroll bars, push buttons, and moving letters/words in display files. You may also add colors to displayed messages or data extracts in SQL.

Colors in CL Programs

Are you bored with reading messages in black and white? Try this code to assign colors to message text:

PGM  PARM(&LIB) 
          DCL &LIB    *CHAR  10
          DCL &R       *CHAR  1 
          DCL &Y       *CHAR  1 
          DCL &W      *CHAR  1 

          CHGVAR &R VALUE(X'28')  /*  Red */ 
          CHGVAR &W VALUE(X'22')  /*White */ 
          CHGVAR &Y VALUE(X'33')  /*Yellow*/ 
  /* Check if library exists           */ 
          IF  COND(&LIB = '   ') THEN(GOTO CMDLBL(EOJ)) 
          CHKOBJ QSYS/&LIB  *LIB 
          MONMSG CPF9801 EXEC(DO) 
          ERR1:    SNDUSRMSG  MSG(&W||'Library' *BCAT &Y||&LIB *BCAT +
                    &R||'does not exist') 
   /* Or display message on Line #24     */
        ERR2:    SNDPGMMSG MSG(&W||'Library' *BCAT &Y||&LIB *BCAT &R|| + 
                          'does not exist')
          ENDDO
 EOJ: ENDPGM 

Colors in SQL Statements

Table ZD: MAKE(10A), MODEL(10A), MLS1(5 0) , MLS2(5 0) is used in the following examples:

MAKE
MODEL
MLS1
MLS2
Toyota
COROLLA
2
8
Nissan
MAXIMA
3
5
Toyota
4RUNNER
2
5
Ford
F150
3
3
Toyota
AVALON
2
2



Now, add colors via hexadecimal values x'22', x'28', x'38', x'20'. (See the CL Reference Manual for a complete list of hexadecimal values for colors.) In order to concatenate a hexadecimal value to a numeric data column, it must first be converted using the CHAR function.

SELECT   x'33'||MAKE MAKE,                                         
  (CASE when make='Nissan' then x'28'||model
              when  make='Toyota' then x'38'||model
              else x'22'||model end) model, x'22'||CHAR(mls1) mls1, x'20'||CHAR(mls2) mls2
 FROM ZD                                                        
 ORDER  BY x'33'||MAKE


You may highlight an entire row for specific selection:

 SELECT
     (CASE when make = 'Nissan'  then 
             x'33'||make else make end) make,

      model, mls1, mls2  FROM ZD                    


Note that columns with added hexadecimal characters are shifted to the right.

Assigning colors is useful to set up visual alerts when exceptions occur. For example: values outside of a specified range, or a JOIN statement that does not return data from a joined table, etc.

--Issak Brender
This email address is being protected from spambots. You need JavaScript enabled to view it.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: