Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5498 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello. I have a Filemaker script which basically does two things:

1) runs a calculated applescript to create a PDF of a web page showing information specific to the record being viewed in the DB.

2) uses the Insert File script step to put the PDF into a container field.

Usually this works well. But sometimes, it takes too long to create the PDF, and step 2 gives an error saying "This file is locked or in use". When that happens, the only button in the dialog box is OK, and when the button is pressed, the script proceeds without having inserted the file. I want to prevent that from happening, but I haven't been able to find an acceptable solution.

I've tried using error capture in the FMP script, but the File In Use error seems uncapturable. (I'd have liked to trap the error and use it to trigger a delay-and-retry.)

There is a 1 second "pause" between steps 1 and 2, which could of course be increased to make sure there's plenty of time for the PDF to be created. (It'd have to be at least 5 seconds.) But considering the script will be run several thousand times, unnecessary delays add up (and frusterate/confuse end users).

Any suggestions on how I could make Filemaker wait until the PDF is created before trying to insert it?

Posted

Timing is often a problem when separate processes are doing things. Usually each one knows when it is done. So what I'd try first is to call the FileMaker script from AppleScript. Pseudo code:

get the web page, as PDF (however)

do script FileMaker script "Insert Web PDF"

It means you need to type the name of the FileMaker script, and be careful not to change the name after that. But it should help with the timing issue.

If not, there are more intense methods to check whether a file is "done being modified." But I've only had partial success with that.

Posted

For some reason I thought that an Applescript run from within FMP couldn't script FMP. Good to know that's not the case, thanks.

The real problem though, is knowing when it's safe to proceed... having the Applescript call a FMP script just begs the question, since the Applescript doesn't know when the PDF is done being created either.

I ended up doing two loops in Applescript, the first one waiting until the file exists, and the second one checking the size of the PDF every .2 seconds until it comes up the same size as it was in the previous iteration. A little kludgy, but it works.

This topic is 5498 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.