Q: display dialog ... giving after integer
After updating to Mountain Lion I experienced some problems with the AppleScript scripts I use in a Filemaker Pro environment.
This necessitated me to change from QTP to QTP 7.
The following script reflects the FMP environment; when I try to abstract from the FMP environment, I encounter other problems.
tell application "QuickTime Player 7" to launch
--------------------------------------------------------------
tell application "FileMaker Pro"
activate
set url_path to cell "bestandspad" of current record
end tell
set tekst to ""
--------------------------------------------------------------------------------
tell application "QuickTime Player 7" to getURL url_path
delay 0.1
tell application "System Events"
set visible of process "QuickTime Player 7" to false
repeat until visible of process "QuickTime Player 7" is false
end repeat
end tell
tell application "QuickTime Player 7" to set doc1Exists to (exists document 1)
if not doc1Exists then
set tekst to "next"
else
tell application "QuickTime Player 7" to play document 1
end if
set the clipboard to tekst
set tekst to ""
--------------------------------------------
repeat
display dialog "Interrupt" buttons {"Stop", "Pauze"} giving up after (my secLeft())
set {b, fin} to {button returned, gave up} of result
if fin then exit repeat
if b = "Stop" then
set tekst to "Stop"
exit repeat
else
tell application "QuickTime Player 7" to pause document 1
display dialog "Verder gaan ?" with title "" buttons {"Stop", "Hervat"} default button 2
set b to button returned of result
if b = "Hervat" then
tell application "QuickTime Player 7"
tell document 1
if duration = current time then exit repeat
play
end tell
end tell
else
set tekst to "Stop"
exit repeat
end if
end if
end repeat
set the clipboard to tekst
on secLeft()
tell application "QuickTime Player 7"
tell document 1
set d to (duration - current time)
end tell
end tell
set d to round d rounding up
if d < 1 then set d to 1
return d
end secLeft
------------------------------------------------------------------------
tell application "QuickTime Player 7" to close document 1 saving no
tell application "QuickTime Player 7" to quit
Everything works fine, but.
The problem is with the 'display dialog ... giving up after (my secLeft())'
This is supposed to return fin=true when current time equals duration or when my secLeft=0; it always returns fin=false
This program runs fine on the AppleScript editor; 'current time' sometimes poses a problem in other programs.
Any idea how to correct 'dispaly dialog (without moving back to QTP)?
iMac, OS X Mountain Lion (10.8.2), FileMaker Pro 11
Posted on Jan 19, 2013 2:04 PM
I don't care for the points, but I have indicate that the problem is solved.
If it interests you, apparently since or as some result of Mountain Lion, the time measured for the duration of a song in the Applescript was no longer in seconds, but in milliseconds times 0.6; this means that a 3 minute song became 180 * 1000 * 0.6 = 108000.
Initially I didn't notice, as iTunes works also in milliseconds; the fixed factor of 0.6 I took for granted.
SecLeft() returned values of several tens of thousands, 'giving up after' was slowly counting in real seconds.
So the program functions as it should, only the time values were mixed up.
Posted on Jan 21, 2013 7:01 AM