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

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

Recommended Posts

Posted (edited)

Hello,

I need a script that can check if a file exists ie. it checks a path and if the file exists it returns for example 1 and 0 if it doesn't exists.

I have a script that does this already, it works great for text-files... however when I tried my same script on .MOV files it crashes 5% of the time (it's always the same files that makes it crash).

My script works like this:

Set variable: $$path, filewin:/H:/files/quicktime.mov

Import ($$path as EXCEL file)

GetError

If (GetError = 700)

Open Url ($$path)

End If

Basically it tries to Import the .MOV file as a EXCEL-file but since it's not an Excel-file, you get a 700 error code. Which tells my script that the file exists and that it can open it. My full script is made up of much more variables.

I know it's "Import Records" that causes this crash because if I disable only "Import Records" in my script, it doesn't crash when you execute the script.

Any help whatsoever is really really appreciated.

*Edit*

Found the MooPlugin, haven't tried it yet. But should probably solve all my problems. But if you have a native solution, I still really want to hear it! Thanks

Edited by Guest
  • Newbies
Posted

Here is a native method

In your file have a Global Container field for this example call it gContainer

Now for the script

Set variable: $$path, filewin:/H:/files/quicktime.mov

Set variable: $$path2, Get ( FilemakerPath ) & "XText.dll"

Insert File: gContainer, $$path <> $$path2

Set Variable: $$FileExists, Case ( gContainer = "XText.dll", 0, 1 )

Basically what is happening is the insert file will insert the first file that it can find. If your movie file exists it will insert that. If it does not it will insert the dll. XText.dll is an application file for Filemaker so it will always be there.

The FileExists variable simply evaluates what file was inserted into the container field. If it is the dll then it couldn't find the movie. If it is not the dll it must be the movie.

  • 2 years later...
Posted

Can someone explain this step from the above protoscript:

Insert File: gContainer, $$Path <> $$Path2

It doesn't map over to anything described in the FMP help entry for Insert File.

The method sounds like a good way to test. I just can't see what the actual step should look like.

Thanks for any help.

Posted

I believe there needs to be a carriage return between the two paths.

Not sure why they need to be global variables, though. And I doubt you will find XText.dll on the Mac platform.

Posted

Thanks for responding ... but I'm afraid I still don't get it. Here's the format I'm looking at:

Insert File: [ Reference ; <table::field> ; "<filename>" ]

Other that seeing that gContainer is the field, nothing else fits.

What would an example of a real script statement need to look like?

Posted

When printed out, the script would look something like this:

Set Variable [ $filePath; Value:"file:RealFile.png" ]

Set Variable [ $altPath; Value:"file:Default.png" ]

Insert File [ Table::gContainer; “$filePath” OR “$altPath” ]

In order to get there, you need to enter the paths as a return-separated list:

post-72594-0-66504000-1327101772_thumb.p

Posted

That makes lot more sense ... having them stacked in the Specify File ... as long as you factor in:

Explicit: FileMaker will search for the path in the order they occur in the list.

Implicit: FileMaker will only load the first file it can locate ... and not each one successively.

It would appear that this is instance of depending on the observed behavior of the software, rather than a declared feature. I'll probably use it, anyway.

Thanks for clearing this up.

Posted

It would appear that this is instance of depending on the observed behavior of the software, rather than a declared feature.

I don't think so. I believe this was intended so you could have alternate paths depending on the platform, for example, or whether the file is served or not (keep in mind that this feature predates using variables as paths).

http://www.filemaker.com/11help/html/create_db.8.32.html#1030283

Posted

Examples of multiple file paths

Use multiple file paths when you want FileMaker Pro to search a list of potential files. File paths are searched in the order in which they appear. FileMaker Pro opens the first file it is able to successfully locate, which completes the search. Each file path must be on a separate line.

Example 1: In this example, a FileMaker Pro database must work on two different operating systems: a Windows system that accesses local Windows files, and a Mac OS system that accesses local Mac OS files. On both platforms, the database must access a local file named test.xls.

filewin:/C:/ExcelFiles/Hosted/test.xls

filemac:/MacintoshHD/ExcelFiles/Hosted/test.xls

Thanks for pointing that out. It clears up a bit more of the fog (for many of us) surrounding cross-platform file references, which helps. Still, my experience is that FileMaker's weakest suit is in regards to file operations under Windows. Although it's out of my realm, I've always assumed things were easier on the MAC, with AppleScript as a resource ... and with FMP's character encoding being "native" for the MAC. I optimistically look forward to improvements in the next FMP version ... but I've done so since 8.0, and not much has changed.

Anyway, thanks.

  • 4 weeks later...

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