difference between function() and function_()

Is there a functional difference between these functions?

someFunction()
or
someFunction_()

and

someFunction(inputVariable)
or
someFunction_(inputVariable)

Does the underscore make a difference in a function’s operation?

Hi,

Yes, there is a difference.
Each underscore character represents the appropriate colon in the Objective-C method

OK I understand that.

But I have functions in my ASOC project that are like this: someFunction(var1, var2) that work properly.
Why would I need to use one versus the other?

It seems to me that if you’re using your own home-rolled functions (within the same script object) that you can get away with not using any underscores, but if you are going to use any Obj-C functions, or your own that reside inside another script object/class, that underscores are necessary.

lets call functions() “applescript handlers”
and functions_() “ASOC methods”

since ASOC can run applescript, an applescript handler will work. The limitation is that you can only call a handler from within the same ASOC class. You can’t link to an applescript handler from Interface Builder to call it, for example, when a button is pressed, or to send it text from a text field. You also can’t call an applescript handler in one ASOC class file form another ASOC class or from an Obj-C class.

An ASOC method, written in applescript, uses the underscore. These can be linked to from IB, or called from another class. (there’s usually some other housekeeping you need to do to do this, but you definitely need to use the underscore).

I see now. Thanks for the clarification. :slight_smile: