home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------------------ */
- /* Macro: COUNTWRD.AML */
- /* Written by: nuText Systems */
- /* */
- /* Description: Counts the number of words in the current file. The */
- /* count is limited to a marked block if it exists in */
- /* the current file. For this macro, words are defined */
- /* to be contiguous sequences of alphabetic characters */
- /* (of any case) and the underline (_) character. */
- /* */
- /* Usage: Select this macro from the Macro List (on the Macro */
- /* menu), or run it from the macro picklist <shift f12> */
- /* ------------------------------------------------------------------ */
-
- // compile time macros and function definitions
- include bootpath "define.aml"
-
- // test for edit windows
- if not wintype? "edit" then
- msgbox "Edit windows only!"
- return
- end
-
- // test if a marked block exists in the current file
- block_count = mark? and getmarkbuf == getcurrbuf
-
- // display message
- say "Counting words" + (if? block_count " in block") + "..."
-
- // count words using regular expression searching
- count = find "[a-zA-Z_]#" "axg" + (if? block_count 'b')
-
- // clear the title bar
- display
-
- // display the word count
- shortbox (if? count (thousands count) "No") + " words found" +
- (if? block_count " in the block")
-
-