Jump to content

  •  

Photo

Timing Out Even with in "with timeout"


  • Please log in to reply
5 replies to this topic

#1 Chuck  Veteran

Chuck
  • Members
  • 975 posts
  • LocationMenifee, CA
  • FM Application:12 Advance
  • Platform:Cross Platform
  • Skill Level:Expert
  • Certification:7, 8, 9, 10, 11
  • Membership:TechNet
  • Time Online: 10h 34m 38s

Posted 29 August 2003 - 02:32 PM

I have an AppleScript that includes the following code:

tell application "Toast Titanium"
activate
make new Data disc
open alias (CDS_TO_BURN_FOLDER & CURRENT_CD_NUMBER)

with timeout of 30000 seconds
write current disc without asking
end timeout
end tell

This code is of course part of a much larger program, but this is were my error is occuring.

When I run this code from within Script Debugger, it works find. The AppleScript waits until Toast is finished burning the disc before continuing. However, when I run the exact same program from within FileMaker, I get the following error from the FileMaker application:

"Toast Titanium got an error: AppleEvent timed out. (Error -1712)."

So, any ideas? How can I get FileMaker to actually wait like the code says to do? According to FileMaker's Knowledge Base article 102246, FileMaker should recognize the "with timeout" construct. Of course the article was originally written in the 2.x days, although it seems to be valid for at least version 5, and I'm using version 6.

I'm interested in the reason this isn't working as well as a fix if possible. The workaround that I've come up with is to enter a loop that tests whether Toast is responding somehow (now sure how I'll do this part yet) and only continue the script when Toast responds successfully.

Thanks,
Chuck
  • 0

#2 jfmcel  master

jfmcel
  • Members
  • 310 posts
  • FM Application:7
  • :

Posted 29 August 2003 - 07:01 PM

With the introduction of Toast 5.x, I've encountered the same problem. This was my work around...

tell application "Toast Titanium 5.0.2"
ignoring application responses
write current disc as session
end ignoring
repeat
with timeout of 3600 seconds
set theStat to status code of current disc
end timeout
if theStat is 0 then exit repeat
if theStat < 0 then
-- do some toast error routine
exit repeat
end if
delay 4
end repeat
end tell
  • 0

#3 Chuck  Veteran

Chuck
  • Members
  • 975 posts
  • LocationMenifee, CA
  • FM Application:12 Advance
  • Platform:Cross Platform
  • Skill Level:Expert
  • Certification:7, 8, 9, 10, 11
  • Membership:TechNet
  • Time Online: 10h 34m 38s

Posted 24 September 2003 - 01:05 AM

Well, I tried your technique but unfortunately had no success.

Here's the entire handler that I'm trying to use to write these CDs from within FileMaker:

to BurnCDs()

  -- A convoluted way to say "Launch Toast using Mac OS X instead of Classic."
  tell application "Finder" to open file (((name of startup disk) & ¬
    ":Applications:") & (name of every folder of folder ¬
    ((name of startup disk) & ":Applications:") whose name contains ¬
    "Toast") & ":" & (name of every item of folder ¬
    (((name of startup disk) & ":Applications:") & ¬
      (name of every folder of folder ((name of startup disk) & ¬
        ":Applications:") whose name contains "Toast") & ":") ¬
      whose name contains "Toast"))

  -- Give Toast a chance to finish launching.
  delay 10

  repeat with thisCD in CD_LIST

    set CURRENT_CD_NUMBER to thisCD
    set userCanceled to false

    tell application "Toast Titanium"

      activate
      make new Data disc
      open alias (CDS_TO_BURN_FOLDER & CURRENT_CD_NUMBER)

      ignoring application responses
        write current disc without asking
      end ignoring -- application responses

      repeat

        with timeout of 3600 seconds
          set theStatus to status code of current disc
        end timeout -- of 3600 seconds

        if theStatus is 0 then
          exit repeat
        else if theStatus is 1 then
          set userCanceled to true
        end if -- theStatus is 0

      end repeat -- empty

    end tell -- app "Toast Titanium"

    if not userCanceled then ¬
      TakeCDOutOfQueue()

  end repeat -- with thisCD in CD_LIST


  tell application "Toast Titanium" to close window 1 without saving

end BurnCDs

I'm pretty sure that I've followed your technique, but I'm still getting a timeout error from Toast, which I sort of expected given that it's still using a with timeout block.

BTW, as long as I've posted this code, you'll see the convoluted way that I'm launching Toast. I did this because whenever I simply used "tell application "Toast Titanium"" to activate, or something similar, Toast would launch in Classic mode instead of Aqua. That first line that targets the Finder basically constructs a path to the Toast application, assuming that it's the only item with the name Toast in a folder that is the only folder with the name Toast in the Application's folder at the root level of the startup drive. I've been told by the client that this assumption is correct, but it's not pretty code. If anyone knows of a better workaround, I'd be happy to hear it.

In the handler, the variables in all caps are actually properties that are declared earlier in the script, so don't worry about them being undefined at this point.

Also, BTW, the status code of the disk returns 0 very quickly. I wouldn't want the repeat loop to exit until the CD had been verified.

Any help would be appreciated.

Thanks,
Chuck
  • 0

#4 jfmcel  master

jfmcel
  • Members
  • 310 posts
  • FM Application:7
  • :

Posted 24 September 2003 - 08:49 PM

From the Toast dictionary, disc status should be...

status code integer [r/o] -- Toast’s current status code: 0 for idle and no error, 1 to 100 for “percent complete”, 101 for “indeterminate”, or a negative value for error codes.

And this works under OS 9.x . But something was lost in translation to the OS X version and disc status seems to consistent return 0. There is an alternative -- busy of application class -- but that doesn't appear to work under OS X either.

There is a Toast Discussion Forum at the Roxio site and there I found the comment, "What happened Toast, it used to work pretty well with applescript it now sucks, when will this be fixed."

and another comment

"Temp Solution is to go back to 5.0.2 it still works."

I have 5.0.2 on my OS 9.2 partition (and that seems to work) while I have 5.2 on my OS X partition. Let me know if you have any luck...
  • 0

#5 Chuck  Veteran

Chuck
  • Members
  • 975 posts
  • LocationMenifee, CA
  • FM Application:12 Advance
  • Platform:Cross Platform
  • Skill Level:Expert
  • Certification:7, 8, 9, 10, 11
  • Membership:TechNet
  • Time Online: 10h 34m 38s

Posted 24 September 2003 - 10:03 PM

Thanks for the info, but neither going to an earlier version nor going to OS 9 are an option. I did get it to work with a kludge, and in fact, the nature of the kludge seems to indicate that the problem lies with FileMaker, not with Toast.

Basically, I saved the script as an applet, and I use the Send Apple Event script step in FileMaker to run the applet. This works. Like I originally said, the only place the script doesn't work is when it is run as an embedded script within FileMaker. I've run it successfully in Script Debugger, Smile and Script Editor, and now as an independent applet. Everything but FileMaker correctly waits for the time indicated within the "with timeout" block.

Thanks for the input. Hope my adventures help someone else in the future.

Chuck
  • 0

#6 jfmcel  master

jfmcel
  • Members
  • 310 posts
  • FM Application:7
  • :

Posted 25 September 2003 - 10:37 AM

Seems like that was the conclusion of a previous thread...

http://www.fmforums....=true#Post17632

It is a strange problem because it seems I've had plenty of instances where the timeout block does work in AppleScripts run within FM (e.g. burning discs with Toast 4.x). It is also annoying that the fix I found for Toast 5.0.2 does not work with newer versions of Toast.

It would be nice if FMI would fix whatever problem they have with their AS complier (this timeout problem has persisted over several versions). The FM applescript dictionary hasn't been expanded since version 3. AppleScript can give you amazing versility in both setting FM data and controlling other applications. There is a sizable community of FM developers that use applescript -- and I participate in the forum to help make that community larger. A little bit of effort from FMI to improve FM AS functionality would be nice.
  • 0




FMForum Advertisers