So, as part of an IBM-i project to “rebuild a bunch of source libraries on the development machine” I always think about backups before touching things. Not because I have history of deleting things (while in rampant house keeping mode) and then regretting it later… we would never do that right? cough
So, since I was playing with hundreds of source files, tens of thousands of source members and squillions of lines of code I thought “Wouldn’t it be nice if I could copy all this source code to the IFS for easy referencing with NOTEPAD++?”
The answer was YES… in true Projex style this turned into a command and CPYSRC2IFS was born.
Copy *SRC to IFS (CPYSRC2IFS) Type choices, press Enter. Source File to be copied . . . . File Name Library . . . . . . . . . . . *LIBL Name, *LIBL, *CURLIB Source Member Name . . . . . . . *ALL Name, generic*, *ALL Type of document to create . . . *TXT Required document format Path Name ie:/HOME/usrprf . . . *HOME Bottom F3=Exit F4=Prompt F5=Refresh F12=Cancel F13=How to use this display F24=More keys
I also added several file formats for the source code once it lands in the IFS: *TXT, *PDF, *XML and *HTML
The nature of this command is to enter something like this:
CPYSRC2IFS FILE(LITTENN/QRPGLESRC) MBR(*ALL) IFSDIR('/home/my-ifs-folder') TIMESTAMP(*YES)
Press enter and let it convert your IBM I source code in to the type of your choice and copy it to the IFS location you specified. It’s a great clean backup technique and also an easy way to grab source code that you might want to email to other people.
While writing the RPG code to cleanup the source member comments before copying to the windows format file structure in the IBMi integrated File System (IFS), I decided to take each source members comments and (a) remove special characters and (b) compress down to single blank spaces between words and then (c) switch them to a ‘_’ character instead.
After lots of trial and error – I came up with a neat little DO loop to compress down any multiple blank spaces in the description text, contained in variable(ParmString):
// ------------------------------------------------------------- * // #SQUISH: Truncate out any Cleans // ------------------------------------------------------------- * Begsr #Squish; Dow %Scan(' ': %TRIMR(ParmString)) > *Zeros; ParmString = %Replace( '' : ParmString : %Scan(' ':%TRIMR(ParmString)) : 1); EndDo; Endsr;
Works like a treat….
/me puts fingers in front of face and ‘squishes your head’
OMG – You just saved my life with this routine!!!! It rocks!!!