Using SQL on System i to color source code and inline comments
Without use of an advanced emulator, how do you color source code? SQL. This tip provides a complete table of valid hex values for display colors and the SQL queries to implement it on your system.
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'
Code:
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:
Query 1: CREATE ALIAS QTEMP/ALIAS# FOR LIB/QRPGSRC (PGM1)
The alias would enable us to access different members of file using SQL.
Query 2: UPDATE QTEMP/ALIAS# SET SRCDTA = SUBSTR(SRCDTA,1,4)||X'22'||SUBSTR(SRCDTA,6,94) WHERE SUBSTR(SRCDTA,7,1) = '*'
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.
Query 3: DROP ALIAS QTEMP/ALIAS#
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.