In addition to what I wrote about in my tip, Using SQL on System i to color source code and inline comments, it...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
is also possible to have multicolored lines for comments using SQL, like the one shown below:
The key to this is inserting hexadecimal codes in the byte prior to the text.
For instance, if you want to highlight some part of the text for source program PGM1 in source file QRPGSRC in library LIB1, use the following queries:
CREATE ALIAS QTEMP/ALIAS# FOR LIB1/QRPGSRC (PGM1)
Now taking the example of the above text, get the position of the text, * on the left is in position 7, M (of MODIFICATION) is in Position 11, D (of DESCRIPTION) is in position 41 and * on the right is in position 70.
If we insert hexadecimal codes into the bytes before the text, we can get multicolored lines.
Position of insertions:
For * Insert White (X'22') in position 6
For M insert Blue (X'3A') in position 10
For D insert Red (X'28') in position 40
For * on right insert White (X'22') in position 69 The query should be built like this:
UPDATE QTEMP/ALIAS# SET SRCDTA = SUBSTR(SRCDTA,1,5)||X'22'||SUBSTR(S RCDTA,7,3)||X'3A'||SUBSTR(SRCDTA,11,29)||X'28'||SUBSTR(SRCDTA,41,28) ||X'22'||SUBSTR(SRCDTA,70,30) WHERE SRCSEQ = 25
After the query, the line will appear as below:
Although the query looks quite complex, it's simple once you understand that the first parameter in SUBST should be position of character and the second parameter should be the difference between the next position of insertion and the position of the character.
The query shown in the example is done on a source file with a length of 112 (100 bytes for SRCDTA). If your source file length is different, change your query accordingly.
Use this query only if your alias is not created in QTEMP. Otherwise it is optional.
DROP ALIAS QTEMP/ALIAS#
- Although the example shown above might not appear very useful, it may be worth a try if you want to highlight something important, such as compilation instructions, during code documentation.
- Always perform a backup before running the queries in case the query is not built correctly.
- For users using Client Access emulators, there is an easy option available from the keyboard map for multicolored comment lines that you can use without running the queries.
We encourage readers to submit a tip on use of the AS/400 system for potential publication. Just click on "Submit a Tip" below.