ASS and main loop/polling?

I’m not sure if this can be done, but here goes.

I want to poll a serial port.
I have my reads/writes to the port working fine via the GUI, but I’d prefer to poll for a read and event drive the writes

As it sits now I click a button to read the current buffer and display in a text field.

Where ever I try to put the repeat loop, it locks up the GUI.

I guess I’m mixing procedural and event driven?

(go easy on me, I’m an X-Code neophyte )

Keep an eye open to ‘unscripted’. Soon a acrticle about backgrounding and callbacks I’ve send to one of the administrators will be posted there.

You problem is that you need to detach code from the main thread of your app to continue the on click handler. The freezing of your interface is logic because the on click is only finished when it comes to ‘end click’. So having an infinite loop results that the end of the click will never been reached and therefore it seems that the gui is freezin. But in fact it’s only waiting till your code is finished before it can accept any other user input.

Cool Thanks!

Thats what I figured was happening.
Funny thing, this isn’t a real program, just a testing tool for another project. But I can see where this ability could come in handy (heck, my first ass program needed it:) )

For polling you could use the idle handler. Don’t use the repeat but only what’s inside the loop. The idle itself is like a infinite loop with a time interval. For a polling application is this very usefull but not for a very busy programm. Just adjust the time interval of the idle handler by returning the number of seconds you have to wait till the next run of idle. Don’t return 0 because this is 30 seconds. You can read more at http://developer.apple.com/library/mac/#documentation/AppleScript/Conceptual/AppleScriptLangGuide/conceptual/ASLR_about_handlers.html