/* REXX */ /* */ /* AUTHOR: Mark Zelden */ /* */ /* Last Updated 10/07/2013 */ /* */ help_start = HELP_INCL() /**********************************************************/ /* This edit macro will FILL column(s) with characters. */ /* The FILL can optionally be limited to specific lines */ /* if labels are used. Excluded lines are omitted from */ /* the operation. */ /* */ /* EXAMPLES: */ /* FILL 1 2 '/' */ /* FILL 2 7 'DELETE' .A .B */ /* */ /* */ /* ** NOTE If you execute FILL 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 (col1 col2 parm label1 label2)" /* Address ISPEXEC "CONTROL ERRORS RETURN" */ If col1 = '?' then do Call HELP_NOTELINES Exit 1 /* return cursor to command line */ End /* check for numeric column numbers */ If col1 <> '' then do If Datatype(col1,Number) <> 1 then do zedsmsg = 'START COLUMN NOT NUMERIC' zedlmsg = 'THE STARTING COLUMN FOR THE', 'FILL MUST BE NUMERIC.' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Exit 12 End If col2 = '' then do zedsmsg = 'NO ENDING COLUMN' zedlmsg = 'AN ENDING COLUMN FOR THE', 'FILL MUST BE SPECIFIED.' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Exit 12 End End If col2 <> '' then do If Datatype(col2,Number) <> 1 then do zedsmsg = 'END COLUMN NOT NUMERIC' zedlmsg = 'THE ENDING COLUMN FOR THE', 'FILL MUST BE NUMERIC.' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Exit 12 End If col2 < col1 then do zedsmsg = 'END COL < START COL' zedlmsg = 'THE ENDING COLUMN MUST BE GREATER THAN OR', 'EQUAL TO THE STARTING COLUMN.' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Exit 12 End End If col1 = '' then do zedsmsg = 'NO STARTING COLUMN' zedlmsg = 'YOU MUST SPECIFY A STARTING COLUMN', 'FOR THE CHARACTER FILL.' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Call HELP_NOTELINES Exit 4 End If parm = '' then do zedsmsg = 'NO FILL CHARACTER' zedlmsg = 'YOU MUST SPECIFY A FILL CHARACTER', 'AS THE THIRD PARAMETER.' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Exit 12 End "(width) = DATA_WIDTH " /* length of line */ width = Format(width) /* remove leading zeros */ If col1 < 1 | col2 < 1 | col1 > width | col2 > width then do zedsmsg = 'INVALID COLUMN NUMBER' zedlmsg = 'ALL COLUMN SPECIFICATIONS MUST BE' , 'BETWEEN 1 AND' width Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Exit 12 End /* make sure data will fit */ parmckl = parm If Substr(parm,1,1) == "'" then parmckl = Strip(Translate(parm,"","'")) If Substr(parm,1,1) == '"' then parmckl = Strip(Translate(parm,'','"')) If col2-col1+1 < Length(parmckl) then do zedsmsg = 'DATA WON''T FIT' zedlmsg = 'FILL DATA WILL NOT FIT IN THE' , 'SPECIFIED COLUMNS' Address ISPEXEC "SETMSG MSG(ISRZ001)" /* msg - with alarm */ Exit 12 End /* */ /* Save current BOUNDS setting */ /* */ "(status) = USER_STATE" /***********************************************/ /* FIND OUT IF LABELS ARE BEING USED */ /***********************************************/ Call FIND_LABELS /***********************************************/ parmck = Translate(parm) If parmck = 'X' | parmck = 'NX' | parmck = '*' , | parmck = '/*' then parm = "'" ||parm|| "'" /***************************************************/ /* Begin changing data */ /***************************************************/ "BOUNDS "col1 col2 "C P'=' ' ' ALL NX "label1 label2 /* all characters */ "C P'=' " || parm || " ALL NX "label1 label2 /* all characters */ /***************************************************/ /* End of changes */ /***************************************************/ /* */ /* Find the number of changed lines and */ /* and save them for later use */ /* */ "SEEK " || parm || " ALL NX "label1 label2 "(junk,count) = SEEK_COUNTS" /* */ /* restore saved BOUNDS setting */ /* */ "USER_STATE = (status)" "RESET CHANGE ERROR" /* */ /* display changed lines count */ /* */ count=count+0 /* remove leading zeros */ zedsmsg = count 'LINES CHANGED' zedlmsg = count 'LINES WERE FILLED WITH "'parm'".' Address ISPEXEC "SETMSG MSG(ISRZ000)" /* msg - no alarm */ Exit 1 /* return cursor to command line */ /*********************************/ /* 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