Any real world examples of "call method" ?

Hi

I would like to learn how to use “call method” to run some Cocoa stuff otherwise not available in Studio, and perhaps also to run some C code I might be able to write myself.

One thing I have a need is in the area of string processing. The handlers I have written in AppleScript are much too slow and I would like to be able to replace them with C code or some Cocoa methods already available.

For example, I have a few handlers that is called from the changed handler whenever a text field was changed in order to make sure the user doesn’t enter any invalid data. One of those handlers enforces that a user enters a proper phone number in the form “(nxx) nxx-xxx” where n >1 and x is any digit.

This is far too slow and I have to set the editable property of the text field to false when entering the changed handler to make sure that the handler isn’t interrupted by further user input (an old Studio bug that causes any Studio application to crash if input is entered too fast or a key is held down), then setting it back to true when leaving the changed handler again. This causes the blue halo indicating the text field has focus to flicker and is a bit ugly.

So, I would like to be able to write that phone format enforcement hander in something faster. I looked at the APIs for NSString and NSscan, but this is just too complicated for me to grasp since I have never done any Objective-C programming. On the other hand, the examples in the Studio Reference are too simple to be of any use.

It would seem that for those of use who learn mostly by example, Objective-C and Cocoa is a book with seven seals. I would appreciate if somebody could point me to resources that explain how to write your own non-Applescript code to be called from AppleScript (or initially how to use some more sophisticated Cocoa stuff like NSstring/NSscan from AppleScript).

thanks
rgds
benjk