CL coding tip #73 – using [COPYRIGHT]

IBM i

Jul 26

Control Language (CL or CLP) has a neat and little used header specification command called ‘COPYRIGHT’

Just like the RPG header level COPYRIGHT parameter we can also do the same thing in CL programs.

By using the COPYRIGHT command in CL we can embed our companies copyright statement into the code for the program.

What does a CL copyright look like?

When you issue a DSPPGM (program-name) you see the comment embedded in the actual program object itself. Here is an example:

CL COPYRIGHT

This code can easily be published system wide by putting it in a COPYBOOK and sucking that into each and every CL we have:

 INCLUDE SRCMBR(CLHEADER)

and the CLHEADER source looks like this:

RPG Code Snippet COPYRIGHT TEXT('THIS PROGRAM IS COPYRIGHT SOME BLOKE + 
 SOFTWARE 2017 + 
 | MODULE:something Date: sometime Author: + 
 somebloke')

NOTE: Obviously you can see that I have typed blank space into that to line it all up nicely when I do a DSPPGM.

ANOTHER NOTE: the COPYRIGHT statement will display when you do a DSPPGM but we can go an extra step and include it with a variable so that it displays in DUMP outputs (not that my code ever dumps of course 😉

DCL VAR(&COPYRIGHT) TYPE(*CHAR) LEN(256) + 
 VALUE('THIS PROGRAM IS COPYRIGHT SOME + 
 BLOKE SOFTWARE + 
 2017 | + 
 MODULE:something Date: sometime Author: +
 somebloke')

ANOTHER DARN NOTE: regular &VARIABLES are not shown in DUMPS until they are used so we can easily *fool* IBM i into using that variable by simply basing something over it – how about something like a lovely little pointer?

DCL VAR(&COPYRIGHTP) TYPE(*PTR) STG(*DEFINED) DEFVAR(&COPYRIGHT)

*BOOM*

Now if the code ever dumps we will see the value in the DUMP as well  🙂

File . . . . . : QPPGMDMP Page/Line 1/1 
Control . . . . . Columns 1 - 130 
Find . . . . . . 
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+....3
 5770SS1 V7R2M0 140418 CL Program Dump AG800 7/26/17 18:28:28 Page 
 Job name . . . . . . . . : QPADEV000Y User name . . . . . . . . : LITTENN Job number . . . . . . . : 034896 
 Program name . . . . . . : RESNETUSR Library . . . . . . . . . : PROJEX4I Statement . . . . . . . . : 0 
 Module name . . . . . . . : RESNETCPP Procedure name . . . . . : QCL_Function_Check_Exception_Handler 
 Messages 
 Message Message From To 
 Time ID Sev Type Text Program Inst Program Inst 
 (No messages found on program's message queue) 
 Variables 
 Variable Type Length Value Value in Hexadecimal 
 *...+....1....+....2....+ * . . . + . . . . 1 . . . . + . . . . 2 . . . . 
 &COPYRIGHT *CHAR 256 'THIS PROGRAM IS COPYRIGHT' E3C8C9E240D7D9D6C7D9C1D440C9E240C3D6D7E8D9C9C7C8
 +26 ' SOME BLOKE SOFTWARE 2017' 40E2D6D4C540C2D3D6D2C540E2D6C6E3E6C1D9C540F2F0F1
 +51 ' ' 404040404040404040404040404040404040404040404040
 +76 ' | MODULE:something Dat' 4040404F40D4D6C4E4D3C57AA2969485A38889958740C481
 +101 'e: sometime Author: someb' 857A40A2969485A389948540C1A4A38896997A40A2969485
 +126 'loke ' 939692854040404040404040404040404040404040404040
 +151 ' ' 404040404040404040404040404040404040404040404040
 +176 ' ' 404040404040404040404040404040404040404040404040

one final NOTE

If you have a bound ILE program – made up of several modules, each with its own copyright statement, then you will see multiple copyright statements when you issue the DSPPGM command. This looks a little messy imho so I normally place the COPYRIGHT in the main MODULE and just have versions information for all the other modules (or service programs) that are in the module list.

So – how about we do the exact same thing in RPG?

Follow

About the Author

IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.