how do I use else if's ?

Hi

In my old xcode applescript application I use a lot of else if’s inside the on clicked handler, how would I do the same in ASObjc?

on clicked theObject
if name of theObject is "A" then
beep 1
else if name of theObject is "B" then
beep 2
else if name of theObject is "C" then
beep 3
end clicked

cheers

on connectThisInInterfaceBuilder_(sender)
if name of theObject is "A" then
beep 1
else if name of theObject is "B" then
beep 2
else if name of theObject is "C" then
beep 3
end
end connectThisInInterfaceBuilder_

BRILLIANT, cheers for that Dylan
:smiley:

ok, I bound connectThisInInterfaceBuilder to a button called A, named button A in the Button Identity panel, nothing happens.

I tried

set name of theObject to connectThisInInterfaceBuilder

thinking this would get the name when clicked, it fails

how would I get when clicked connectThisInInterfaceBuilder to get the name of theObject and beep as required?

The best answer is probably that you wouldn’t. Instead of the ASStudio way of one handler for all clicks, in ASObjC you’re more likely to make separate handlers for each button (unless they do the same thing).

cheers for the input Shane