Your script is hogging the cpu. You can quit the script with the keystrokes Command + “.” (period). This causes an error. There is a better way to write your script though instead of hogging the cpu. You might use an idle handler where it gives up the cpu for a certain amount of seconds. Or you could use the ‘sleep’ unix command maybe. But somewhere in the back of mind I’m thinking about something connected to the logout.
My “real” script executes a shell script (curl) on an equipment on my local network, a scale that displays a certain weight. Then if the weight on the scale changed, it writes a line with the new weight on a log file.
The script is fully functional today, except for the fact that I have to kill it before logging out.
I would like to have the script running on another computer on the network. But can’t do it now because of the fact that it would prevent people from logging out.
This is why I posted this topic.
I tryed once a “on idle” aproach. But this made my script completely useless.
In fact my script use a “repeat while true” statement.
Could you post me an example of how you would aproach the problem with an idle handler?
Actually the comparable scri pt wou ld look like this:
property repeat_time : 5
on idle
beep 1
return repeat_time
end idle
Instead of hogging the cpu, it gives up the cpu for 5 seconds. Then it returns and beeps 1 time. The only problem is the 1 second limit on the idle time and you have to save it as stay open application.
Your original script would look like this:
property repeat_time : 5
global the_count
on run
set the_count to 0
end run
on idle
beep 1
set the_count to the_count + 1
if the_count = 100 then quit – don’t put this in a tell block
return repeat_time
end idle