How can you run _(sender) handler as a sub-routine within the script?

Hey guys,

long time lurker here, i just can’t find documentation on this issue i’m having. I’ve probably just overlooked an obvious source.

How can i run a _(sender) handler as a sub-routine within the script? Every time i try to run it i get an error. I can figure out a work around, but I feel like there should be an easier way to accomplish this.

EXAMPLE

on doSomething_(sender)
--tell block that does something
end doSomething

on doAnotherThing()
doSomething()
end doAnotherThing

This results in an error. I also tried replacing doSomething() with doSomething_() and doSomething_.

CURRENT WORKAROUND

on doSomethingSender_(sender)
doSomething()
end doSomethingSender

on doSomething()
--tell block that does something
end doSomething

on doAnotherThing()
doSomething()
end doAnotherThing

This allows the handler to be connected to something in the interface and it allows me to run the doSomething handler as a sub-routine within the script itself.

I feel like this is a little overkill and i just don’t know the syntax to run a the “DoSomething_(sender)” within the script.

Also, i’ve been applescripting for a little while now and i’m just making the switch to ASOBjC & xcode. If there are any tips or tricks that you guys have i would greatly appreciate you sharing!

Thanks guys!

You were so close in your first attempt. You just needed the underscore and “me” as the parameter.

on doSomething_(sender)
--tell block that does something
end doSomething

on doAnotherThing()
doSomething_(me)
end doAnotherThing

Don’t worry, I had to ask the same question when I first started working with ASOC.:wink:

Brad

Haha. Awesome thank you :slight_smile: I knew there had to be an easier way to do it.