/* REXX */ /* */ /* AUTHOR: Mark Zelden */ /* */ /* Last Updated 10/07/2013 */ /* */ help_start = HELP_INCL() /**********************************************************/ /* This edit macro will add a character string suffix */ /* to the end of a line after the last non-blank */ /* character. The suffix can optionally be limited to */ /* specific lines if labels are used. Excluded lines */ /* are omitted from the operation. */ /* */ /* EXAMPLES: */ /* SUFFIX "'" */ /* SUFFIX ',DISP=SHR' .A .B */ /* */ /* */ /* ** NOTE If you execute SUFFIX with no parms or with */ /* a parm of "?", the comment section of this */ /* code with examples will be displayed as */ /* "help" note lines. Use the "RESET" */ /* command to remove them. */ /* */ /**********************************************************/ help_end = HELP_INCL() /* TRACE ?R */ Address ISREDIT "MACRO (parm label1 label2)" /* Address ISPEXEC "CONTROL ERRORS RETURN" */ /* */ If parm = '?' then do Call HELP_NOTELINES Exit 1 /* return cursor to command line */ End If parm = '' then do zedsmsg = 'NO SUFFIX SPECIFIED' zedlmsg = 'YOU MUST PASS A PARM STRING', 'FOR SUFFIX TO ADD.' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Call HELP_NOTELINES Exit 4 End /* */ Call FIND_LABELS /* find out if labels are being used */ /* */ /* HOUSE KEEPING */ /* */ "(width) = DATA_WIDTH" /* length of line */ count = 0 /* count of changed lines */ truncat = 0 /* lines truncated count */ truncmsg = "'*** THE SUFFIX WAS TRUNCATED ON THE NEXT LINE ***'" /* */ /* If the suffix is is delimted by single or */ /* double quotes - then remove the delimiters */ /* */ If Substr(parm,1,1) = '''' | Substr(parm,1,1) = '"' then parm = Substr(parm,2,Length(parm)-2) /***********************************************/ /* BEGIN SUFFIX PROCESSING */ /***********************************************/ Do until lastln = firstln-1 /* copy the data in the current line to variable 'data1' */ "(data1) = LINE "firstln "ISREDIT (chkexcl) = XSTATUS" firstln If chkexcl = "NX" then do data1 = Strip(data1,T) data1 = data1||parm count = count + 1 If Length(data1) > width then do truncat = truncat+1 "ISREDIT LINE_BEFORE" firstln "= NOTELINE " truncmsg End End /* copy the suffixed 'data1' back into the current line */ "LINE" firstln "= (data1)" firstln = firstln + 1 End /* do until */ /***********************************************/ /* END SUFFIX PROCESSING */ /***********************************************/ If truncat = 0 then do zedsmsg = count 'LINES CHANGED' zedlmsg = 'SUFFIX "'parm'" WAS ADDED ON' count 'LINES.' Address ISPEXEC "SETMSG MSG(ISRZ000)" /* msg - no alarm */ Exit 1 /* return cursor to command line */ End Else do zedsmsg = 'TRUNCATED ON' truncat 'LINES' zedlmsg = 'SUFFIX "'parm'" WAS ADDED ON' count 'LINES', '('truncat 'LINES WERE TRUNCATED).' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Exit 4 End /*********************************/ /* HELP SUB-ROUTINES */ /*********************************/ HELP_INCL: Return SIGL HELP_NOTELINES: "(helpln) = DISPLAY_LINES" Do hlp = help_end-1 to help_start+1 by -1 hline = Sourceline(hlp) "ISREDIT LINE_AFTER " helpln " = NOTELINE (hline)" End hline2 = '===================' hline3 = '=== H E L P ===' "ISREDIT LINE_AFTER " helpln " = NOTELINE (hline2)" "ISREDIT LINE_AFTER " helpln " = NOTELINE (hline3)" "ISREDIT LINE_AFTER " helpln " = NOTELINE (hline2)" Return /*********************************/ /* SUB-ROUTINE TO FIND LABELS */ /*********************************/ FIND_LABELS: Address ISPEXEC "CONTROL ERRORS RETURN" If label1 = '' then do firstln = 1 "(lastln) = LINENUM .ZLAST" End Else do If label2 = '' then label2 = label1 "(firstsv) = LINENUM" label1 If RC >= 8 then do zedsmsg = 'RANGE LABEL ERROR' zedlmsg = 'THE SPECIFIED RANGE LABEL "' || label1 '" WAS', 'NOT FOUND' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Exit 12 End "(lastsv) = LINENUM" label2 If RC >= 8 then do zedsmsg = 'RANGE LABEL ERROR' zedlmsg = 'THE SPECIFIED RANGE LABEL "' || label2 '" WAS', 'NOT FOUND' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Exit 12 End firstln = Min(firstsv,lastsv) lastln = Max(firstsv,lastsv) Address ISPEXEC "CONTROL ERRORS" End /* else do */ Return