home *** CD-ROM | disk | FTP | other *** search
- REM Description: Count words or sentences
- REM Filename: count.wmc
- REM Created by: Robin Fried and Steven Wylie - 11/08/93
-
- REM Can't run if no document open
- IF GetDocName$() = "" THEN
- MESSAGE "Please create a new document or open an existing document first."
- STOP
- ENDIF
-
- REM Can't run in a graphic or table frame
- frameType% = GetFrameType()
- IF frameType% <> 0 THEN
- Message "The current frame must be a text frame."
- STOP
- ENDIF
-
- DIM typeStr$(2)
- DIM whereStr$(5)
-
- typeStr$(1) = "characters"
- typeStr$(2) = "words"
-
- whereStr$(1) = "entire document"
- whereStr$(2) = "current story"
- whereStr$(3) = "current frame"
- whereStr$(4) = "current column"
- whereStr$(5) = "selected text"
-
- sel% = GetTextOffset(start%, end%)
-
- IF sel% = 1 THEN where% = 4
- type% = 1
-
- BEGIN DIALOG Dialog1 134, 110, "Count"
- GROUPBOX 4, 4, 80, 34, "Type:"
- OPTIONGROUP type%
- OPTIONBUTTON 14, 14, 64, 10, "&Characters"
- OPTIONBUTTON 14, 24, 64, 10, "&Words"
- GROUPBOX 4, 40, 80, 64, "Where:"
- OPTIONGROUP where%
- OPTIONBUTTON 14, 50, 64, 10, "Entire &Document"
- OPTIONBUTTON 14, 60, 64, 10, "Current Stor&y"
- OPTIONBUTTON 14, 70, 64, 10, "Current &Frame"
- OPTIONBUTTON 14, 80, 64, 10, "Current Co&lumn"
- OPTIONBUTTON 14, 90, 64, 10, "&Selection"
- OKBUTTON 90, 4, 40, 14
- CANCELBUTTON 90, 20, 40, 14
- END DIALOG
-
- BEGIN DIALOG Dialog2 134, 80, "Count"
- GROUPBOX 4, 4, 80, 34, "Type:"
- OPTIONGROUP type%
- OPTIONBUTTON 14, 14, 64, 10, "&Characters"
- OPTIONBUTTON 14, 24, 64, 10, "&Words"
- GROUPBOX 4, 40, 80, 34, "Where:"
- OPTIONGROUP where%
- OPTIONBUTTON 14, 50, 64, 10, "Current Stor&y"
- OPTIONBUTTON 14, 60, 64, 10, "&Selection"
- OKBUTTON 90, 4, 40, 14
- CANCELBUTTON 90, 20, 40, 14
- END DIALOG
-
- IF GetEditor() = 1 THEN ' Page Editor
- ret% = Dialog(dialog1)
- ELSE
- where% = sel%
- ret% = Dialog(dialog2) ' Draft Editor
- IF where% = 0 THEN
- where% = 1
- ELSE
- where% = 4
- ENDIF
- ENDIF
-
- if ret% = 2 THEN STOP
-
- if type% = 0 THEN
- count% = CountCharacters(where%)
- else
- count% = CountWords(where%)
- endif
-
- messageText$ = "There are "+str$(count%)+" "+typeStr$(type%+1)+" in the "+whereStr$(where%+1)+"."
- Message(messageText$)
-
- ***** WARNING *****
- This is a WSWin macro file.
- Subsequent data is binary information and should not be modified.