home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / DOS / TEKST / AURORA2 / COUNTWRD.AML < prev    next >
Text File  |  1995-04-28  |  2KB  |  41 lines

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