Home > AS/400 Tips > iSeries programmer tips > Using SQL on System i to create multicolored comment lines
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Using SQL on System i to create multicolored comment lines


Narendra Devireddy, Contributor
08.25.2008
Rating: -3.82- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


In addition to what I wrote about in my tip, Using SQL on System i to color source code and inline comments, it 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#

Please note:

  1. 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.
  2. Always perform a backup before running the queries in case the query is not built correctly.
  3. 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.

Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
iSeries programmer tips
Enhancing RPG with external SQL stored procedures
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
Implementing a browser interface in COBOL: Displaying database fields
Taking advantage of CL advancements, starting with V5R3
TAATOOL: Useful tools for programmers on IBM i
Implementing a browser interface in COBOL: Creating your graphic Web page
Implementing a browser interface in COBOL: Getting started
Making the most of RPG data handling on IBM i
Groovy programming on IBM i

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts