/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* Rexx - Renumber component/add fixtags */ /**********************************************************************/ /* Renumbers line numbers in a component (Source/Copybook) */ /* NOTE - Switches on NUM & replaces blindly. Use with C A U T I O N */ /**********************************************************************/ /* ______ ______ _ _ _ _ ______ ______ _ _ | ______ */ /* |____/ |_____ \__/ \__/ |_____ | | | --+-- |_____ */ /* | \_ |_____ _/ \_ _/ \_ |_____ |_____ |____| | |_____ */ /* */ /**********************************************************************/ /* Author - thecodeisclear */ /* Version - 1.10 Language - REXX */ /* Purpose - Renum set of lines as per given input */ /* Input - strt - starting number/fix tag (Compulsory) */ /* <strt-lbl> - starting label. Default first line (Optional) */ /* <end-lbl> - ending label. Default last line (Optional) */ /* <incr> - increment. Default 100 (Optional) */ /* Output - Code is modified in the same dataset */ /**********************************************************************/ /* - - > M O D L O G < - - */ /* 04/17/07 : Fixed bug when field 'strt' has leading zeros FX041707 */ /* 10/15/10 : Provided an option to add fix tags instead of EH101510 */ /* doing the renumber. incr will become optional */ /* */ /* */ /* */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Turn on Signal to trap all errors/failures/syntax errors */ signal on error signal on syntax signal on failure "ISREDIT MACRO (strt l1 l2 incr) NOPROCESS" If rc /= 0 then do say 'Edit environment not set' exit end "ispexec control errors return" If strip(strt) = '' then do say 'Usage : rnum strt <strt-lbl> <end-lbl> <incr>' say ' ' say ' strt - starting value/fix tag to add' say ' <strt-lbl> - starting label. Default first line.' say ' <end-lbl> - ending label. Default last line.' say ' <incr> - increment. Default 100' exit end If strip(incr) = '' Then incr = 100 If strip(l1) = '' Then l1 = .zf If strip(l2) = '' Then l2 = .zl If datatype(strt) /= 'NUM' then do "ISREDIT C ALL P'========' 73" strt l1 l2 /*EH101510*/ End Else Do If datatype(incr) /= 'NUM' then do say 'The increment counter must be numeric' exit end /* To remove leading zeros in the strt variable */ strt = strip(strt,'L',0) /*FX041707*/ width = length(strip(strt,b,'''')) If width > 6 Then Do Say 'Length of counter cannot be longer than 6 characters' exit End nChg = 0 crc = 0 Do while crc = 0 strtx = strt if strt < 100000 then strtx = "0" || strt if strt < 10000 then strtx = "00" || strt if strt < 1000 then strtx = "000" || strt if strt < 100 then strtx = "0000" || strt strtx = "'" || strtx || "'" "ISREDIT C 1 P'======' NEXT " strtx l1 l2 crc = rc nChg = nChg + 1 strt = strt + incr /* --- If after inc > 999999 exit --- */ If strt > 999999 Then Do say ' ' say ' - - - E R R O R - - - - - - - - - -' say ' Line number exceeds 999999. Completed ' || nChg || ' updates.' say ' Exiting now. Press Cancel to avoid saving the code.' say ' ' say ' - - - S U G G E S T I O N S - - - -' say ' 1. Provide start and end labels. (or)' say ' 2. Give a smaller start/increment number.' Exit 8 End End End /* End for strt check numeric */ /* --- Go back to first location after Change --- */ Address ISREDIT "locate " l1 Exit /* - - - - S U B R O U T I N E S - - - - - */ /* */ error: syntax: failure: Address TSO "clear" Say "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- E R R O R -=-=-=-=-=-=-" Say "An error occured during the execution of this utility. An error" Say "log has been created and stored. To track the status of this" Say "error, please contact the author with the reference" Say "ERR==>" sourceline(SIGL) Say "Con==>" condition('D') Say "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" ht_exit: /* Turn on Signal Processing to prevent infinite loops */ signal off error signal off syntax signal off failure /* Generic Exit Paragraph. */ If datatype(ex_rc) ¬= 'NUM' Then Do ex_rc = 0 End lgRC = ex_rc Exit ex_rc