Address "ISREDIT"; /*REXX*/ "MACRO (PRM1 PRM2 PRM3 PRM4 PRM5 PRM6 PRM7 PRM8 PRM9 PRM10", "PRM11 PRM12 PRM13 PRM14 PRM15 PRM16 PRM17 PRM18 PRM19", "PRM20) NOPROCESS" /* COLSUM was changed for PC-side and copied back for TSO */ /* to correct the TSO version. It has not be retested on TSO */ /* D.McRitchie 05/08/1997 due to unavailability */ /*********************************************************************/ /* COLSUM Calculate the sum of specified columns within */ /* NX cc-range or label-range */ /*********************************************************************/ /* F. David McRitchie, "The REXX Macros Toolbox", April 04, 1991 */ /* col-pairs (required) indicate column of numbers to be totalled */ /* either lptr-range or cc-range must be used for correct results */ /* lptr-range specify lines to be included using labels */ /* cc-range specify included lines using CC-range notation */ /*********************************************************************/ /* 111 333 4444 555 -- Used with builtin testing defaults*/ /* 222 000 -1111 -222 */ /* -.02 000 -1111 -222 */ /*********************************************************************/ tok.="" If PRM1 = '' then do; ZEDSMSG = "column pairs" ZEDLMSG = 'Column pairs are required to ', ||'indicate what columns are to be added' "LINE_BEFORE .ZCSR = NOTELINE (ZEDLMSG)" Address "ISPEXEC SETMSG MSG(ISRZ000)" RETURN 1 End; Labels = 0 Pairs = 0 Do I = 1 to 19; x = value("PRM"I) If substr(x,1,1) = '.' then do If DATATYPE(substr(x,2),"A") then do If LabFrom = "LABFROM" then LabFrom = x Else LabTo = x Labels = labels + 1 end else do ZEDSMSG = "Invalid Label(s)" ZEDLMSG = "Labels must be alphabetic after period" Address "ISPEXEC SETMSG MSG(ISRZ001)" EXIT 4 end end else do pairs = pairs + 1 TOK.i = value("PRM"I) end end if labels = 2 then do "(LNEBGN) = LINENUM " LabFrom "(LNEEND) = LINENUM " LabTo end else do "PROCESS RANGE C" rch = RC If rch = 0 then do "(ZFRANGE) = LINENUM .ZFRANGE" "(ZLRANGE) = LINENUM .ZLRANGE" labels = 2 End Else do If rch = 4 then do "(ZFRANGE) = LINENUM .ZFIRST" "(ZLRANGE) = LINENUM .ZLAST" /*zfrange = 13; zlrange = 15 */ labels = 2 End Else do "LINE_BEFORE .ZFIRST = NOTELINE ", "'ISREDIT PROCESS C or RANGE CC return code is" rch"'" return 4 end End if labels \= 2 then do if labels \= 0 then do ZEDSMSG = 'Label Pair' ZEDLMSG = "Exactly two labels should comprise a" , "label range, not" pairs Address "ISPEXEC SETMSG MSG(ISRZ001)" EXIT 4 end end LNEBGN = ZFRANGE LNEEND = ZLRANGE end If LNEEND < LNEBGN then do x = LNEBGN LNEBGN = LNEEND LNEEND = x end IF LNEBGN = 0 THEN LNEBGN = 1 "LINE_BEFORE" LNEBGN "= NOTELINE """||TIME('N')||" START OF", "COLSUM -- NX LINES" LNEBGN "TO" LNEEND"""" Do J=1 to 20; sum.J=0;end; maxj=0; Do I = LNEBGN to LNEEND by 1 /* while TO5 \= "TO5" */ "(XLINE) = LINE " I "(XSTATUS) = XSTATUS " I If xstatus = "NX" then do Rowtot = 0 Do J = 1 to 19 by 2; jp1 = J+1 If DATATYPE(tok.j,"N") then If DATATYPE(tok.jp1,"N") then do bb = tok.jp1 - tok.J + 1 addend = substr(XLINE,tok.J,bb) If DATATYPE(addend,"N") then do sum.J = sum.J + addend Rowtot = Rowtot + addend End End End If Rowtot \= 0 then "LINE_AFTER" I "= NOTELINE ""ROW total is " Rowtot """" End End sumtot = 0; "(LASTLN) = LINENUM .zlast" If lastln \= LNEEND then LNEEND = LNEEND + 1 Do J=1 to 19 by 2; jp1 = J + 1; If sum.J \= 0 then do sumtot = sumtot + sum.J "LINE_BEFORE" LNEEND "= NOTELINE """||TIME('N') , "SUM of NX COLS " tok.J||"-"||tok.jp1||",total is" sum.J"""" End End "LINE_BEFORE" LNEEND "= NOTELINE '"||TIME('N'), "---------------Total of SUMS is " sumtot "'" "LINE_BEFORE" LNEEND "= NOTELINE """||TIME('N')||" -END- OF", "COLSUM -- NX LINES" LNEBGN "TO" LNEEND"""" "Loc " LNEBGN "UP 10" 