hi all,
I have been playing with the call method to create a repeat loop which counts time using an NSDate.
Does the memory allocated by creating myDate from the NSDate get deallocated at the end of the applescript method or does it accumulate each time the applescript method is called.
–tellboy
set myDelay to 0.005
set myDate to call method "date" of class "NSDate"
set tOldSecs to call method "timeIntervalSinceNow" of myDate
set tNewSecs to call method "timeIntervalSinceNow" of myDate
repeat until (tOldSecs - tNewSecs) > myDelay
set tNewSecs to call method "timeIntervalSinceNow" of myDate
end repeat
log (tOldSecs - tNewSecs)
What are you trying to accomplish with this?
It seems to me it is difficult to break out of a repeat loop by the use of say the escape key within AS.
You can do this as documented elsewhere by the use of an offscreen button clicked by the use of the escape key, setting a flag and then exiting the loop on testing the flag.
However, if you have a delay set by the applescript command of say delay 3 seconds which is within that loop then pressing the escape key does not register until the end of 3 seconds meaning you have to hold down the escape key for 3 seconds before it registers.
I thought the use of creating my own delay in a repeat loop would allow the exiting before the end of the delay period.
This sample code does work in this regard if you insert the test for the escape key flag in the loop.
–tellboy