Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Add words to the spelling dictionary via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Add words to the spelling dictionary via AppleScript
Authored by: DougAdams on May 02, '07 08:06:00AM
Worked for me after I logged out and back in. Also, watch out for how the script compiles. This is how I reformatted it in Script Editor (adding nothing, just moving stuff around a little):
set additions to ""
set finished to false
repeat until finished is true
	display dialog "Enter the next word to add to the user dictionary." & return & 
		"Press the Finished button when you're finished" with title 
		"Add words to spelling dictionary" default answer 
		"" buttons {"Cancel", "Finished", "Add word"} default button 3
	if button returned of the result is "Finished" then
		exit repeat
	else
		set additions to (additions & the text returned of the result as text) & (ASCII character 0)
	end if
end repeat

set UserFile to choose file with prompt 
	"Please choose the dictionary file to add the words to." default location 
	alias ((path to library folder from user domain as text) & "spelling")
set fileRef to open for access UserFile with write permission
set starting_point to (get eof of fileRef) + 1
write additions to fileRef starting at starting_point
close access fileRef

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

Add words to the spelling dictionary via AppleScript
Authored by: klktrk on May 02, '07 03:39:44PM
A little redundancy in the script: At the top of the loop you have:
set finished to false
repeat until finished is true
but then the loop is broken with
if button returned of the result is "Finished" then
		exit repeat
Shouldn't that be
if button returned of the result is "Finished" then
		set finished to true


[ Reply to This | # ]
Add words to the spelling dictionary via AppleScript
Authored by: DougAdams on May 03, '07 08:18:07AM
If I may suggest: actually you don't need the "until" or finished variable at all. The routine would work just as well as:
set additions to ""
repeat
	display dialog "Enter the next word to add to the user dictionary." & return & 
		"Press the Finished button when you're finished" with title 
		"Add words to spelling dictionary" default answer 
		"" buttons {"Cancel", "Finished", "Add word"} default button 3
	if button returned of the result is "Finished" then
		exit repeat
	else
		set additions to (additions & the text returned of the result as text) & (ASCII character 0)
	end if
end repeat
No matter what, the only two ways out of the loop are to click "Finished" or "Cancel", the latter aborting the script entirely.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

Add words to the spelling dictionary via AppleScript
Authored by: blgrace on May 02, '07 03:45:49PM

Didn't work for me.
The script functions correctly and it does add my new words to the appropriate file: ~/Library/Spelling/en_AU (in my case) - but anything added this way does not seem to be recognised.
The added words are still flagged even after logging out and back in.

If I add the same word again using the "Learn" function inside spell check, then it works. Looking at my en_AU file, there are duplicates.

I'm at a loss as to why this might be.



[ Reply to This | # ]