Presumably, this h-spec function was originally implemented by IBM so that software houses can embed their object copyright within the program source. But us RPG developers are a resourceful lot, and the H SPEC COPYRIGHT statement is an excellent way of storing the current modification version of any given program object.
Sometimes, I am working on a version of a program and planning on making many changes during the coming days or maybe weeks. For structured testing of these code versions, or to allow a different colleague to work on a ‘code-frozen’ earlier version, I might want to store the iterative versions in different levels of a testing environment. You could do this by changing the program object description to add a version number V1.1, V1.2, V1.3, V2 etc But this it can be far too easy to have a fat finger moment, or to just forget.
Simples — using the COPYRIGHT H-SPEC actually embeds the version number within the program object itself.
By adding the H COPYRIGHT comment into the first line of code, means we can look at the compiled version (and of course the related source code if you have it) and clearly see the version number. For example, adding something like:
H COPYRIGHT('My Company © 2017 YADA YADA | Nick Litten V1R1 last changed July 2017')
to a program and compile it.
This text is free-format and can contain a character literal with a maximum length of 256.
So, when you issue a DSPPGM (program-name) you see the comment embedded in the actual program object itself. Here is an example from the Projex4i Toolkit:
Super useful and easy way of recording the source code changes.
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.
Copyright and RPGLE for the New Year
CL coding tip #74 – using [CTL-OPT COPYRIGHT]
CL coding tip #73 – using [COPYRIGHT]
What is IBM i Email and SPF?
Updating Numeric DTAARA in RPGLE
How to capture IBM-i job info for submitted jobs
Register license key in SOFTLANDING SOFTMENU
Going the (Levenshtein) Distance in RPG Free
Don’t hardcode library names in your TURNOVER SQL source #youbigsilly