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

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