Hi. I’m improving my text-to-speech script again. I have this:
set myText to text returned of (display dialog "What text do you want converted to speech?" default answer "Small Guy says Hi!" default button 2) as text
set myMinutes to text returned of (display dialog "How long do you want it repeated (in minutes)?" default answer "1" default button 2) as number
set timeA to current date
repeat
say myText
if (((current date) - timeA) / minutes) ≥ myMinutes then exit repeat
end repeat
Is there a way to have a radio button in the beginning (1st or 2nd screen) that lets me choose if I want it repeated on a basis of either a) a matter of minutes (like I have now) or b) a count of repeats? This would be appreciated. Thanks!
you can’t use radio buttons in standard applescript but you could name your buttons.
set myText to text returned of (display dialog "What text do you want converted to speech?" default answer "Small Guy says Hi!" default button 2) as text
set userResonse to (display dialog "How long do you want it repeated?" buttons {"Cancel", "Times", "Minutes"} default answer "1" default button 2)
set theValue to text returned of userResonse
set repeatKind to button returned of userResonse
if repeatKind is "Times" then
repeat theValue times
say myText
end repeat
else if repeatKind is "Minutes" then
set endTime to (current date) + theValue * minutes
repeat until (current date) > endTime
say myText
end repeat
end if