May 30

0 comments

Controlling DSPF color without using indicators

By NickLitten

May 30, 2011

dds, dspf, Indicators, RPG

Code400.com is probably the best RPG programming related forum around (Bob Cozzi’s comes in a close second but the UI is just awful and I really cant spend to long trying to navigate around without getting annoyed… but I digress…). I frequently read neat little tricks and this is a smart one I saw a while back. Was just thinking about it and decided its worth a blog… why not – it’s a quiet news day?

http://www.code400.com/forum/showthread.php?t=7764 JamieF (the Site admin) posted this:

Controlling DSPF color

A*%%TS SD 20090803 105249 FLANARY REL-V5R4M0 5722-WDS
A*%%EC
A DSPSIZ(24 80 *DS3)
A R DUMMY
A ASSUME
A 1 3' '
A**************************************************************************
A R WINDOW1
A*%%TS SD 20090803 105249 FLANARY REL-V5R4M0 5722-WDS
A CF03(03)
A CF06(06)
A WINDOW(12 11 4 50 *NOMSGLIN)
A WDWBORDER((*COLOR BLU) (*DSPATR RI)-
A (*CHAR ' '))
A ATR_DACONM 1A P
A MYFIELD 20A O 1 16DSPATR(&ATR_DACONM)
A 3 2'F3=Exit'
A COLOR(BLU)
A 3 11'F6=Change Color'
A COLOR(BLU)

and the associated RPG code for this would be:

 f@CST25AD cf e WORKSTN
 d EndScreen1 s 1 inz('N')
 d count s 1 0
 d Normal c X'20'
 d Red c X'28'
 d White c X'22'
 d Blue c X'3A'
 d Pink c X'38'

 /Free

 //--------------------------------------------------------
 // MAIN PROGRAM
 //--------------------------------------------------------

 myfield= 'some text';
 dow endscreen1 = 'N';
 exfmt window1;
 select;
 when *in03;
 endscreen1 = 'Y';
 when *in06;
 count +=1;
 if count = 6;
 count = 1;
 endif;
 select;
 when count = 1;
 atr_daconm = normal;
 when count = 2;
 atr_daconm = red;
 when count = 3;
 atr_daconm = white;
 when count = 4;
 atr_daconm = blue;
 when count = 5;
 atr_daconm = pink;
 endsl;
 endsl;

 enddo;
 *inlr = *on;

 /end-free

It just goes to show that theres lots of ways to skin a cat… I love this one!

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips

>