Applescript Timers

There seems to be a difficulty in my xcode project with getting the idle routine to pop. It does if I call it explicity (IDLE) on awake from NIB or any other event routine. However I was expecting it to pop on a regular basis once it was initialized by using a “return 1” for example. In other words I expected the idle routine to be run every second. That is not what is happening. It never gets executed except when I explicitly call it.

What I’m look for is a timer object like I am used to in VB.net or C#.net. You enable it and it pops (or calls it timer event) when the elapsed time is finished. It never stops doing that until you disable it. That is what I need here.

I have looked at objc timers such as:

[NSTimer scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(stepAnimation:)
userInfo:nil
repeats:YES];

but I don’t know how to make it ‘call’ my applescript routine.

I assume I would set something as the target that would then execute the applescript handler.

Any help here?

Regards

GESmith

I don’t know the answer to my question but I do know why the idle routine wasn’t responding unless explicitly called.

I did not associate the file owner object with it in the interface builder. So therefore it wasn’t being called by the system on a regular basis.

What I did was go to the interface builder for the main menu.nib in the project (cocoa of course). I clicked the file owner instance and in the inspector I selected the applescript option. There I clicked the idle option and indicated my main applescript file. After that things worked as expected. This is really simple but very obscure. None of the books I have suggest if you want to add a timer that gets fired on a routine basis then do this to get it going.

Once learned never forgotten.

Regards

George Smith

Hi George,

I looked in the reference manual and it says this in the second paragraph:

“You connect an idle handler to the application object.”

But I must admit that it took me a while to find the applicaiton object in Interface Builder.

gl,

Yes but for someone just starting that sounds like jiberish.

It would have been much clearer if it said you connect an idle handler via interface builder and the file owner instance. Click on the file owner instance, bring up inspector, go to the applescript tab … etc.

But you are correct. It does say it. I still think it’s obscure.