Here is a common example of something I encounter regularly, and never quite know how to solve:
If for example, I am in the beingIdle handler:
on beingIdle()
repeat
set x to (random number from 6 to 25)
repeat
if x = 0 then exit repeat
set x to x - 1
tell window "myWindow"
set myDisplay to "Delay " & x & " seconds"
set the contents of text field "myField" to myDisplay
delay 1
end tell
end repeat
set theList to {"i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8", "i9", "i10", "i11", "i12", "i13", "i14", "i15", "i16", "i17", "i18", "i19", "i20", "i21", "i22", "i23", "i24"}
set myChoice to (my playMySound(theList))
my updateText(mySound, myChoice)
end repeat
end beingIdle
Simply waiting a random delay, and then playing a sound and updating the myField window with the other handlers: playMySound and updateText (which aren’t relevant)…
Now… I have a menu option for a pause function:
on choose menu item theObject
if name of theObject is "myPause" and theSection > 1 then
if pauseState is false then
set pauseState to true
set originalDisplay to contents of text field "myField" of window "bootykon"
tell window "myWindow"
set myDisplay to "Paused..."
set the contents of text field "myField" to myDisplay
end tell
if myState then pause mySound
repeat
delay 1
end repeat
else if pauseState is true then
if (pause of mySound) as boolean then resume mySound
set pauseState to false
end if
end if
end choose menu item
Pausing works great… However, if I unpause, how can I get back to where ever I was before pause was pressed? It’s not as simple as just recalling the beingidle handler, because you could be within one of many handlers, which some are much more complicated-- playing a series of audio items in sequence… and if you pause, I need to be able to pick up exactly where I was…
Is there any way to store “where you are”, and return to there?
thank you.
-patrick