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

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

Recommended Posts

Posted

I have a script that uses Send Event to initiate a third-party file conversion and then waits for the result in the form of a named file on a specific directory. Even though I use Set Error Capture [On], FileMaker intercedes and informs the user that "File is locked or in use", instead of letting my script handle the error.

I thought using error capture would prevent such messages from going to the user. In fact, a reputable manual states simply that: "during scripting ... developer's are in a position to trap and examine the error codes FileMaker generates." The general sequence of my script is:

[color:orange]Send Event: ... pause 2 seconds, then:

Set Error Capture [On]

Import Records [No dialog; File.txt]

Set Variable [$Error; Value:Get(LastError)]

If [$Error = 0] .... done, otherwise wait in 10-second loop

Have I missed something in my steps? Or does FileMaker always step in in certain instances? If so, which ones? Obviously, File.txt will be "busy" while the conversion takes place (the reason for the 10-second loop, although conversions typically take only a couple of seconds). BTW, the conversions do take place correctly and the result files are written.

Any help will be greatly appreciated. Thanks in advance.

Posted

I'm not on windows, but why not make a batch script loop until the file actually exists ... or you could find a method here:

http://www.connectingdata.com/downloads.htm

...to do what you wish to do!

--sd

Posted

Thanks for the response. Actually, I'm already using the loop method I think you're suggesting.

[color:orange]If [$Error = 0] .... done, otherwise wait in 10-second loop

Although my example steps don't show it exactly, the 10-second loop encompasses the Import Records step.

Apparently, the result file is created as a first step in the conversion process -- and is still being used by that process upon the first attempt at importing .... which is why FileMaker reports it "in use".

So my question remains Why doesn't the Set Error Capture [On] cover this situation? All I want is for it to work as described in this excerpt from another FileMaker book:

This script step suppresses the FileMaker Pro error dialogs and messages. This provides the developer with the opportunity to write scripts to handle errors in a manner that is customizable and appropriate to the function being performed.

Posted

No it's not what I meant, we have the same syncing or concurrency issues with applescript, but then is it solved by cutting the native script into two and let the external scripting initiate the continuation of the second part.

To answer you question, would I guess a hierarchy of warnings exists and some of those simply can't be shortcutted.

--sd

Posted

Yes, open files are a problem. The file exists almost immediately, but that doesn't mean you can read it. Combined with the fact that FileMaker considers Import errors to be beyond the normal error capture, you've got a real dilemma.

On the Mac side we have a command line tool which supposedly can tell if a file is still open, and a few other methods.* I've had some, but not 100% success experimenting with them. Usually the tool you use for processing the file handles this. If I call a Unix command line tool to convert a file, then do something with it, it does not proceed to the next step until the file is converted and written to disk.

*One method, if you can use a command to read the last line of the file before you begin processing, is to Loop/Pause then try and read that line from the new file.

I know all of this is of little help, as you are on Windows. All I can say is that I commiserate, and wish FileMaker would give us a "capture all errors" option. Perhaps something on Wim's site will help. I thought I saw that one of the VB examples could call a FileMaker script. That would allow you to test the file within VB, then call the final FileMaker script.

  • 2 weeks later...
Posted

Fenton and Søren, please excuse my delayed response.

FileMaker considers Import errors to be beyond the normal error capture

This was what I didn't know about -- and, of course, it explains everything (except why they don't mention it, instead of making the statement I highlighted above). Now. I'll see what other method I can devise to set some completion indicator in order to get around this awkward message.

Thanks to you both for your insights and suggestions.

Posted

This script step suppresses the FileMaker Pro error dialogs and messages. This provides the developer with the opportunity to write scripts to handle errors in a manner that is customizable and appropriate to the function being performed.

I read this as only internal functions, not external script steps.

Lee

This topic is 6108 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.