Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Check if a file exists?

Featured Replies

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

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...

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.

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.

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?

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

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.

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

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.

Why don't you just use MooPlug? :-S

  • 4 weeks later...

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.