home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / dos / tools / aurora21 / deldup.aml < prev    next >
Text File  |  1995-08-10  |  2KB  |  69 lines

  1.  
  2. /* ------------------------------------------------------------------ */
  3. /* Macro:        DELDUP.AML                                           */
  4. /* Written by:   nuText Systems                                       */
  5. /*                                                                    */
  6. /* Description:  This macro deletes contiguous duplicate lines in the */
  7. /*               current edit window. The total number of lines       */
  8. /*               removed is displayed.                                */
  9. /*                                                                    */
  10. /* Usage:        Select this macro from the Macro List (on the Macro  */
  11. /*               menu), or run it from the macro picklist <shift f12> */
  12. /*               This macro will run faster if Undo is turned OFF.    */
  13. /* ------------------------------------------------------------------ */
  14.  
  15.   include bootpath "define.aml"
  16.  
  17.   var lastline
  18.   var shownext
  19.  
  20.   // test for edit windows
  21.   if not wintype? "edit" then
  22.     msgbox "Edit windows only!"
  23.     return
  24.   end
  25.  
  26.   oldsize = getlines          // save the number of lines in file
  27.   undobegin                   // group this together as one undoable action
  28.   row 1                       // goto the first line
  29.   lasttext = gettext          // get first line in variable lasttext
  30.  
  31.   if down then                // goto the next line
  32.  
  33.     // do for all lines
  34.     loop
  35.  
  36.       // show progress every 150 lines
  37.       if getrow > shownext then
  38.         say (getrow)
  39.         shownext = shownext + 150
  40.       end
  41.  
  42.       // if this line is the same as the last line then delete it
  43.       if gettext == lasttext then
  44.  
  45.         // delete line and test for end-of-file
  46.         if delline > getrow then
  47.           break
  48.         end
  49.  
  50.       // ..otherwise save line text for the next comparision
  51.       // and goto the next line
  52.       else
  53.         lasttext = gettext
  54.         if not down then
  55.           break
  56.         end
  57.       end
  58.  
  59.     end
  60.  
  61.   end
  62.  
  63.   undoend                       // end of undoable group
  64.   display                       // update display
  65.  
  66.   // tell the user how many lines were removed
  67.   say  (thousands oldsize - getlines) + " lines were removed"
  68.  
  69.