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

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

Recommended Posts

Posted

Hi this is really beggining to bug me now (put lightly!) :

I have a filepath that is set through variables, part of my script does the following...

Insert File into container X using variable Y as the filepath.

Now sometimes the file may not exist under this exact filepath and/or name so I need to do the following...

If file not found show custom dialogue file not found please select another > insert as reference into container X and reset variable Y using this filepath and continue inserting the file elsewhere.

What filemaker does is throw up "File blahblah, cannot be found" , then displays the insert file dialogue, which is not acceptable as the end users are easily confused and need a custom dialouge telling them what happened.

If I run the script with and without error capture on, and data view the Get (Last Error) step it returns only 1 if cancel is pressed or 0 if an alternate file is selected.

I want to stop the insert file dialogue popping up if the predefined file is not found.

I even tried if Get (Last Error) ≠ 0

and that still doesn't work becuase FileMaker automatically wants the user to select the file to insert.

HELP ME PLEEEEAAAASSSEEEE

Posted

I wish I could help, but unfortunately I just struggling with exactly the same problem. I hate that you can't turn off the file open dialog that comes up if the path fails. Let's hope there's someone who found away around this.

Posted

I can think of a fairly easy way to do this, but it would be platform-specific, unless you used a file-manipulation plug-in. For a Mac you can use AppleScript to see if the file exists. You'd need to convert your file path to the old Mac standard, with ":"

tell application "Finder"

exists file "Macintosh HD:Users:fej:Documents:FileMaker:FM Clients:Someone:9-26-06.zip"

set r to result as string

end tell

r will be either "true" or "false", which you could then set to a FileMaker global field (cell).

Much the same as seeing if a picture file still exists, in this thread:

http://www.fmforums.com/forum/showtopic.php?tid/183503/post/235357/hl//

Don't know about Windows; but it's bound to be somewhat similar. Anyone?

Posted

the scripting is just as easy on Windows:

Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists(filespec) Then

...< do something > ...

end if

what's hard is returning the result into FM since FM has no built-in support for that on Windows.

Posted (edited)

I suppose to make the script universal I could do this...

>>>

If Get ( SystemPlatform ) = -1

Perform Mac Stuff

Else

Perform PC Stuff

<<<

My problem is as Wim rightly states returning the result into FM as most users for this are PC I need to get that option back into the script to continue one way or the other.

In fact I am shocked FileMaker doesn't have any form of validate file or directory path options as it clearly has the ability to do this within the FileMaker Server Admin when coding backup schedule filepaths.

If one wanted to perform predefined content extraction or dynamic saving of database information with predefined filepaths, surely you would want to validate the path so that if it doesn't exist you could route the script to do something else like ask for an alternate or sendmail to alert the developer.

Edited by Guest
Posted

It's actually now:

If ( Abs ( Get (SystemPlatform)) = 1;

Mac;

PC )

Because, on 8.5 anyway, Mac Intel machines return 1, while previous Mac machines return -1.

So, to pursue the point on PC, would what Wim wrote be a file, which you'd open with Send Event? What would its extension be? Could it then write to another little file, in the section? To what known location?

FileMaker could then import that little file to see whether the other file existed or not. Seems like a long way around, but I imagine it would be quick enough.

Posted

So, to pursue the point on PC, would what Wim wrote be a file, which you'd open with Send Event? What would its extension be? Could it then write to another little file, in the section? To what known location?

VBscripts are plain text files with the ".vbs" extension.

You can have FM generate one through "export field contents" after you generate the whole VBscript syntax in a field. That way, the location of the VBscript can be dynamic.

Or you can write a VBscript that totally lives outside of FM and that you call and pass it a command line parameter. This method is slightly easier to create, but has more potential deployment issues.

Execution is always through Send Event.

the would be two things:

- create a little text file for FM to import

- call a FM import script

FileMaker could then import that little file to see whether the other file existed or not. Seems like a long way around, but I imagine it would be quick enough.

Sounds long, but it really is quick. And there are no timing issues when the FM script stops at the VBscript execution and the VBscript then calls the FM import script.

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