This is probably really obvious but I am overlooking something.
In my IBAction (which works fine) I have an AppleScript handler which is not working. My handler looks like this:
and XCode is giving me this error
Is there something I can do to the IBAction (put it in brackets?) so that it will not get the handler confused with the begging of another IBAction?
Any help would be greatly appreciated.
I’m confused about what you’re asking here – what is is your IBAction? Is the code you are showing here inside another method (the one you are calling an IBAction)? Please post the whole IBAction.
You forgot to put an underscore at the end of the method name as well as sender as the parameter. Of course, if testHandler is your IBaction…
on testhandler_(sender)
display dialog "hello world"
end testhandler_
return testhandler_(me)
Browser: Safari 6533.18.5
Operating System: Mac OS X (10.6)
Thanks for the help. the handler I posted is inside my IBAction. I have posted my whole AppDelegate.applescript file below. And this is the error that xcode is giving me:
oscript testAppDelegate
-- Inheritance
property parent : class "NSObject"
-- IBOutlets
-- property NAME : missing value
-- IBActions ( button clicks )
on doAction_(sender)
on testhandler()
display dialog "hello world"
end testhandler
return testhandler()
end
##################################################
# Application
on awakeFromNib()
-- Code here
end awakeFromNib
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return true
end applicationShouldTerminate_
end script
Well, you can’t put a handler inside a handler, so that might be your problem. You can call another handler from inside one though. But in your case why not just execute the code as is inside the ibaction handler? You can put whatever you want in there, it’s not limited to a few lines or a call to another handler. Just remove the on testhandler lines and see what it does.
Fred
Browser: Safari 6533.18.5
Operating System: Mac OS X (10.6)
That is what I needed to know…Thanks so much leonsimard.
The code I am actually working with has several handlers so I will just have to move them outside.
Thought it might be the reason. Made the same mistake myself in the beginning. 
If I may, you should get Shane Stanley’s book on ASOC. REALLY made a difference for me. Besides it is so far the only one of it’s kind. But he goes really far, worth the price.
Once you get a hold of ASOC you’ll be amazed at what can be achieved!
Good luck,
Fred
Browser: Safari 6533.18.5
Operating System: Mac OS X (10.6)