© unbekannterKÜNSTLER@newsgroup

Das Makro löscht direkt aufeinanderfolgende, doppelte Sätze. Der zu vergleichende Spaltenbereich kann angegeben werden. Fehlt die Angabe, werden die Boundary-Grenzen berücksichtigt.

Die Daten können auf Wunsch vorher sortiert werden.

/* REXX - #DELDUP EDIT MACRO ***********************************/
/* Remove duplicates from columns i-j (i,j are parameters)     */
/* if i or j are not specified, they default to Boundaries     */
/*-------------------------------------------------------------*/
/* This macro uses one trick to improve performance:           */
/*    Many excludes and a final delete is faster than          */
/*    individual line deletes.                                 */
/*-------------------------------------------------------------*/
Address isredit
"MACRO (LCOL,RCOL)"                      /* macro with 2 parms */
"(LBND,RBND) = BOUNDS"                  /* save old Boundaries */
lbnd = abs(lbnd)
rbnd = abs(rbnd)
"(DW) = DATA_WIDTH"                  /* Tet maximum data width */
if lcol > rcol then do
   lcol = bitxor(lcol,rcol)             /* turn left and right */
   rcol = bitxor(rcol,lcol)
   lcol = bitxor(lcol,rcol)
end
if datatype(lcol,'N')=0 then lcol=lbnd      /* Set left column */
if datatype(rcol,'N')=0 then rcol=rbnd     /* Set right column */
"(LAST) = LINENUM .ZLAST"           /* Get number of last line */
"RESET X"                              /* Un-Exclude all lines */

say "Erst Sortieren j/N (Stelle" lbnd "bis" rbnd")";pull antwort
if antwort="J" then do
   "BOUNDS"                                /* reset boundaries */
   "sort &LBND &RBND A"         /* sort between old boundaries */
   "BOUNDS = (LBND,RBND)"              /* set boundaries again */
end
len=abs(rcol-lcol)+1             /* Get length of compare area */
Do linenum = 1 to last               /* Loop through all lines */
  "ISREDIT (LINE) = LINE "linenum   /* Put line data in 'line' */
  test=substr(line,lcol,len)        /* Take columns to compare */
  If test = testold Then         /* Compare with previous line */
    "ISREDIT XSTATUS "linenum" = X"  /* If match, exclude line */
  testold = test             /* Save current line compare area */
End
"ISREDIT DEL ALL X"           /* Finally, delete excluded lines*/
Exit 1
zurück zu Edit Makros