Re: is delay broken in JSA
Re: is delay broken in JSA
- Subject: Re: is delay broken in JSA
- From: Shane Stanley <email@hidden>
- Date: Wed, 17 Dec 2014 10:03:41 +1100
On 17 Dec 2014, at 1:52 am, Deivy Petrescu <email@hidden> wrote:
> And interestingly enough, this can not be used as a workaround since apparently AS can not run the first script in JS.
>
> <script>
> set c to current date
> run script "delay 3" in "Javascript"
That also suggests it's implemented differently.
The delay command does a bit more than just hold things up. For example, if you take my original script and replace the 'delay 3' with 'do shell script "sleep 3"', it doesn't behave the same. If you then move the mouse around (a lot, admittedly), you will see the spinning cursor. And if you hit the Stop button, most times it will be ignored. The delay command does stuff to make sure the interface remains responsive while the script waits.
So if you want to use 'do shell script "sleep x"' instead of delay, you're better off doing it in a loop of delays of, say, .1 seconds:
repeat 30 times
do shell script "sleep 0.1"
end repeat
Or use a handler like this:
on delay delayTime
set theRepeat to delayTime * 10 div 1
repeat theRepeat times
do shell script "sleep 0.1"
end repeat
end delay
--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden