home *** CD-ROM | disk | FTP | other *** search
/ Bila Vrana / BILA_VRANA.iso / 028A / AUROR.ZIP / DELBLANK.AML < prev    next >
Text File  |  1996-07-17  |  2KB  |  60 lines

  1. //--------------------------------------------------------------------
  2. // DELBLANK.AML
  3. // Delete Blank Lines, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro deletes blank lines in the current edit window. The
  6. // operation is confined to a marked block if one exists. Note: this
  7. // macro will run faster if Undo is turned Off on the Set menu.
  8. //
  9. // Usage:
  10. //
  11. // Select this macro from the Macro List (on the Macro menu), or run it
  12. // from the macro picklist <shift f12>.
  13. //--------------------------------------------------------------------
  14.  
  15. include bootpath "define.aml"
  16.  
  17. variable count
  18.  
  19. // test for edit windows
  20. if not wintype? "edit" then
  21.   msgbox "Edit windows only!"
  22.   return
  23. end
  24.  
  25. // test if a marked block exists in the current file
  26. block_count = mark? and getmarkbuf == getcurrbuf
  27.  
  28. // display message
  29. say "Deleting blank lines" + (if? block_count " in block") + "..."
  30.  
  31. // set search options
  32. options = "x*" + (if? block_count 'b')
  33.  
  34. // save cursor position and goto first line
  35. pushcursor
  36. gotopos 1 (if? block_count (getmarktop) 1)
  37.  
  38. // mark the beginning of an undoable group of operations
  39. undobegin
  40.  
  41. // search for blank lines using regular expressions
  42. while find "^ *$" options do
  43.   delline
  44.   count = count + 1
  45. end
  46. breakoff
  47.  
  48. // mark the end of an undoable group of operations
  49. undoend
  50.  
  51. // restore cursor
  52. popcursor
  53.  
  54. // clear the title bar
  55. display
  56.  
  57. // display the count
  58. shortbox  (if? count (thousands count) "No") + " lines deleted" +
  59.           (if? block_count " in the block")
  60.