diff options
author | Teddy Wing | 2018-10-08 17:20:06 +0200 |
---|---|---|
committer | Teddy Wing | 2018-10-08 17:20:06 +0200 |
commit | e627e55bc24355cf33fff2aceb704298085bc681 (patch) | |
tree | d38d00cb0a80963d2b04f7e519453cb3234a096b /Word Count | |
parent | b8a8936c84afc47d8c789a452db8bc2d174cc34f (diff) | |
download | Word-Count-e627e55bc24355cf33fff2aceb704298085bc681.tar.bz2 |
Update the window with character, word, and paragraph counts
Turns out you have to call Objective-C methods, weird. Never seen that
syntax in AppleScript before. Neat though once you know.
Diffstat (limited to 'Word Count')
-rw-r--r-- | Word Count/AppDelegate.applescript | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Word Count/AppDelegate.applescript b/Word Count/AppDelegate.applescript index e42da45..38a3c2e 100644 --- a/Word Count/AppDelegate.applescript +++ b/Word Count/AppDelegate.applescript @@ -11,9 +11,22 @@ script AppDelegate -- IBOutlets property theWindow : missing value + property theCharacters : missing value + property theWords : missing value + property theParagraphs : missing value on applicationWillFinishLaunching_(aNotification) - -- Insert code here to initialize your application before any files are opened + tell application "TextEdit" + set top_document to document 1 + + set l_chars to count characters of top_document + set l_words to count words of top_document + set l_paragraphs to count paragraphs of top_document + end tell + + theCharacters's setStringValue_(l_chars) + theWords's setStringValue_(l_words) + theParagraphs's setStringValue_(l_paragraphs) end applicationWillFinishLaunching_ on applicationShouldTerminate_(sender) |