Using SQL on System i to color source code and inline comments

Narendra Devireddy, Contributor
This tip was submitted by a reader and reviewed and revised by Search400.com expert John Blenkinsop for accuracy and thoroughness. A follow-up tip is planned by the author, but please let us know if you have any questions regarding this tip.

For all those programmers using emulators other than Client Access (and other similar advanced emulators), you can color your source code/inline comments using SQL. The color codes for some are as given below:

Red X'28'
White X'22'
Blue X'3A'
Pink X'38'
Turquoise X'34'


In SQL/400, create an alias of the source member you want to color in QTEMP. If I want to color source member PGM1 in QRPGSRC my SQL statement would be something like:


The alias would enable us to access different members of file using SQL.


We are updating the source line by including hex color code in sixth byte of the source.

This query would change the color of all comment line to white.

Condition your query as you like based on any field SRCDTA, SRCSEQ, SRCDAT.


This drops the alias file created in QTEMP.

The table of valid hex values for display colors is shown below:

Hex Color
20 Green
21 Green, reverse image
22 White
23 White, reverse image
24 Green, underscore
25 Green, underscore, reverse image
26 White, underscore
27 Nondisplay
28 Red
29 Red, reverse image
2A Red, high intensity
2B Red, high intensity, reverse image
2C Red, underscore
2D Red, underscore, reverse image
2E Red, underscore, blink
2F Nondisplay
30 Turquoise, column separator
31 Turquoise, column separator, reverse image
32 Yellow, column separator
33 White, reverse image, column separator
34 Turquoise, underscore, column separator
35 Turquoise, underscore, reverse image, column separator
36 Yellow, underscore, column separator
37 Nondisplay
38 Pink
39 Pink, reverse image
3A Blue
3B Blue, reverse image
3C Pink, underscore
3D Pink, underscore, reverse image
3E Blue, underscore
3F Nondisplay

We encourage readers to submit a tip on use of the AS/400 system for potential publication. Just click on "Submit a Tip" below.

This was first published in May 2008

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.