+Happy New Year 2018. One of my new years resolutions was to write cleaner code, and in the spirit of out with the old and in with the new…
Lots of IBM i shops have old AS400 and iSeries RPG applications that have evolved over the years. They are still using the good old fashioned compile time array (aka table) technique to store COPYRIGHT information in their RPG and RPGLE programs.
Perhaps, 2018 is the time to upgrade this old RPGLE Compile Time Array technique with a newer dcl-s statement technique?
It’s less code, simpler to write, saves a lot of time and therefore money 😉
Upgrading the COPYRIGHT technique in RPG and CL
Add a member(copyright) to a standard copybook:
dcl-s CopyrightCompanyName varchar(256) inz('Application Version x.y Copyright © SOMETHING LLC 2018 - Program Property of SOMETHING LLC. All Rights Reserved.'); dcl-s Copyright_ptr pointer inz(%addr(CopyrightCompanyName));
The CopyrightCompanyName variable is the copyright and the Copyright_ptr pointer tricks IBM I into flagging it as used, so it shows in program dumps without having to MOVE or EVAL.
Then each program just has one line in it
• No need for array definition
• No need for c-spec move statement
• No Need for footer table in each program
• No code changes needed if copyright is updated — copybook member(copyright) will be automatically picked up as each program is recompiled
The same technique can be used for CLLE programs using CLP INCLUDE and the same copyright statement in a CL copybook.
The CL Looks like this:
DCL VAR(©RIGHT) TYPE(*CHAR) LEN(256) + VALUE('Application Version x.y Copyright © SOMETHING LLC 2018 - Program Property of SOMETHING LLC. All Rights Reserved.') DCL VAR(©RIGHTP) TYPE(*PTR) STG(*DEFINED) DEFVAR(©RIGHT)
I hope that helps somebody else out there suffering from post christmas blues. Or at least gives you some food for thought.
Talking about food… where is that Turkey Sandwich??
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.
+Happy New Year 2018
What is AS400 modernization?
IBM i ACS 5250 EMULATOR FONT – and other ridiculous mumbo jumbo
IBM i SQL statement to convert or compare hundred year date format
How to compare ‘100 Year Date’ to a Timestamp – aka – Weird AS400 iSeries Date formats
Modernize AS400 iSeries Queries – Convert to IBM i SQL
Use IBM i SQL to validate email addresses in Customer Master File
Set off all RPG Indicators in a program
Better performance for re-entrant programs aka reduce static storage