Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Question:

Question: AppleScript under 10.7 Lion

Hello everyone,


first, I am a beginner with apple and mac os.


I have wrote a script for 10.6 to use the spellchecker within my Java-Program:


tell application "Automator Runner"

set mySpellChecker to call method "sharedSpellChecker" of class "NSSpellChecker"

set foundLanguages to call method "availableLanguages" of mySpellChecker

end tell


which works nice under 10.6


But now under 10.7 even under the applescript console an error occurs at:


tell application "Automator Runner"

set mySpellChecker to call method "sharedSpellChecker" of class "NSSpellChecker"

set foundWords to call method "availableLanguages" of mySpellChecker

end tell


> Expected end of line but found identifier.


Can anyone please give me a hint, what has changed from 10.6 to 10.7. In the Changelog I cant find either an AppleScript change or a change with the spellchecker API. Also other scripts from the web using the "to call method ..." fails with the same error.


Thanks for any reply in advice

Michael Coldewey

Mac OS X (10.7.2)

Posted on

Reply
Question marked as Helpful

Nov 10, 2011 5:45 PM in response to coldy77 In response to coldy77

That Automator Runner trick was just a way to access Cocoa methods via its AppleScript Studio terminology - in your case, call method. In Lion, the AppleScript Editor can use AppleScriptObjC (introduced in Snow Leopard), which calls Cocoa methods directly. ASOC is the current framework, so Apple has been gradually removing the old AppleScript Studio stuff (which is deprecated) to "encourage" its use.


There are a couple of ways to use AppleScriptObjC in your script. The first is to create a new Cocoa-AppleScript Applet from AppleSccript Editor's File > New from Template menu item - this is the easiest, but you can't run your script from the Editor (you need to run the applet), which makes debugging a bit of a pain. The second way is to use the ASObjC Runner background application, which can be run from the AppleScript Editor (it also takes care of coercing results from Cocoa methods to their respective AppleScript classes). Either way, your script snippet would look something like (including coercing the resulting NSArray to a list):


setmySpellCheckertocurrent application's NSSpellChecker's sharedSpellChecker()

mySpellChecker's availableLanguages() aslist

There’s more to the conversation

Read all replies

Page content loaded

Question marked as Helpful

Nov 10, 2011 5:45 PM in response to coldy77 In response to coldy77

That Automator Runner trick was just a way to access Cocoa methods via its AppleScript Studio terminology - in your case, call method. In Lion, the AppleScript Editor can use AppleScriptObjC (introduced in Snow Leopard), which calls Cocoa methods directly. ASOC is the current framework, so Apple has been gradually removing the old AppleScript Studio stuff (which is deprecated) to "encourage" its use.


There are a couple of ways to use AppleScriptObjC in your script. The first is to create a new Cocoa-AppleScript Applet from AppleSccript Editor's File > New from Template menu item - this is the easiest, but you can't run your script from the Editor (you need to run the applet), which makes debugging a bit of a pain. The second way is to use the ASObjC Runner background application, which can be run from the AppleScript Editor (it also takes care of coercing results from Cocoa methods to their respective AppleScript classes). Either way, your script snippet would look something like (including coercing the resulting NSArray to a list):


setmySpellCheckertocurrent application's NSSpellChecker's sharedSpellChecker()

mySpellChecker's availableLanguages() aslist

Nov 10, 2011 5:45 PM

Reply Helpful (1)

Nov 11, 2011 2:29 AM in response to red_menace In response to red_menace

Thx for the answer again...


Now i try this simple script with install ASObjC Runner installed:


--------------


script spellcheckerscript

-- set the mySpellChecker to current application's NSSpellChecker's sharedSpellChecker()

-- set the theResult to mySpellChecker's availableLanguages()

set theResult to "Hello World"

return theResult as Text

end script


tell application "ASObjC Runner" to set theResult to run the script {spellcheckerscript} with result returned


--------------


Now AppleScript Console says: "Expected End of Line but found identifier". Providing "passing" argument also ends with this error message.


Sorry for questioning again, but i am new to this stuff...


Thx for Answers and best regards

Michael Coldewey

Nov 11, 2011 2:29 AM

Reply Helpful

Nov 11, 2011 4:41 PM in response to coldy77 In response to coldy77

If you haven't run it yet, double-click on the ASObjC Runner application to get it out of quarantine and registered. If the AppleScript Editor still doesn't see it, you can do something like tell application "x" and choose the application when asked where it is.

Nov 11, 2011 4:41 PM

Reply Helpful
User profile for user: coldy77

Question: AppleScript under 10.7 Lion