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

  1. /* ------------------------------------------------------------------ */
  2. /* Macro:        COUNTWRD.AML                                         */
  3. /* Written by:   nuText Systems                                       */
  4. /*                                                                    */
  5. /* Description:  Counts the number of words in the current file. The  */
  6. /*               count is limited to a marked block if it exists in   */
  7. /*               the current file. For this macro, words are defined  */
  8. /*               to be contiguous sequences of alphabetic characters  */
  9. /*               (of any case) and the underline (_) character.       */
  10. /*                                                                    */
  11. /* Usage:        Select this macro from the Macro List (on the Macro  */
  12. /*               menu), or run it from the macro picklist <shift f12> */
  13. /* ------------------------------------------------------------------ */
  14.  
  15.   // compile time macros and function definitions
  16.   include  bootpath "define.aml"
  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 "Counting words" + (if? block_count " in block") + "..."
  29.  
  30.   // count words using regular expression searching
  31.   count = find "[a-zA-Z_]#"  "axg" + (if? block_count 'b')
  32.  
  33.   // clear the title bar
  34.   display
  35.  
  36.   // display the word count
  37.   shortbox  (if? count (thousands count) "No") + " words found" +
  38.             (if? block_count " in the block")
  39.  
  40.