ISPEDIT Macro - Sum some columns

Sample
ISPF Edit Macro - Sample

Beispiel:                                 

/* REXX YSUM Copyright YCOS Yves Colliard Software 1990-2009 */
/* TRACE ?R  */
  /* einschalten des interaktiven Trace Modus */
  /* */
/***  REXX  **********************************************************/
/*  Funktion:  summieren von Columns im editierten Source            */
/*  Aufruf:    YSUM Startcol Endcol                                  */
/*             nur "nicht X" Zeilen                                  */
/*  Egebniss:  Total value 21 Avg 4.20 Anz 5/7 (columns 4 to 10)     */
/*********************************************************************/
/* */
numeric digits 20
/* */
Address ISREDIT "MACRO (scol,ecol)"
Address ISPEXEC "CONTROL ERRORS RETURN"
Address ISREDIT "(TLINE) = LINENUM .ZLAST"
if scol > ecol ,
! scol = "" ,
  then do
    zedsmsg = "invalid column range"
    zedlmsg = "End column must not be lower than start column"
    Address ISPEXEC "SETMSG MSG(ISRZ001)"
    exit
  end
l = ecol-scol+1
totnum = 0
totx   = 0
totanz = 0
do i = 1 to tline
  Address ISREDIT "(xstat) = XSTATUS "i
  if xstat = "X" then do
    totx = totx + 1
  end
  else do
    Address ISREDIT "(tl) = line "i
    num = substr(tl,scol,l)
    if datatype(num) = "NUM" then do
       totnum = totnum + num
       totanz = totanz + 1
    end
  end
end
totanz=max(totanz,1)
zedsmsg = ""
zedlmsg = "Total value "totnum" Avg "format(totnum/totanz,,2),
"Anz "totanz"/"totanz+totx "(columns "scol" to "ecol")"
Address ISPEXEC "SETMSG MSG(ISRZ001)"