Jump to content
Server Maintenance This Week. ×

Conditional Logic Outside of FileMaker


Ted S

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

Recommended Posts

Hello,

c:directory_1directory_2

I'm running FM6.0 on W2K & XP and I would like to write a script that opens the Windows Explorer (explorer.exe) in directory_2 if it exists, if it doesn't exist then open in directory_1. The name of directory_2 is contained in a field within FileMaker and directory_1 is always the same but directory_2 may or may not actually exist.

Any ideas?

Link to comment
Share on other sites

Are you trying to display a list of files for the user to select? If you use a file plugin like Troi File, which would enable you to determine if the folder existed and to popup a file list? If you're set on using explorer.exe, I would think that you'll need a way to change the "current" directory (which I would guess is stored in the registry). You could also use WinBatch web page , which can perform all kinds of file and directory manipulations.

Link to comment
Share on other sites

I should have been more clear. I'm really only trying to get the Windows Explorer to start in the folder that is named in one of the FileMaker fields.

This is a reference database where we contain information about our products but some of the products have additional info contained in Word & Excel documents for instance. I want to have a button that will take the user to the proper folder if there is one or leave them one folder up if there isn't.

I would like to do this without any plug-ins if possible.

Link to comment
Share on other sites

I don't know what version 7 allows, but in prior versions there is no way to know whether a folder exists without using a plugin. Given how Filemaker doesn't seem to want to step on the plugin developers, I would bet that v7 is no better in terms of relating to the operating system. That said, I would highly recommend Troi File (and Dialogs) to make what you want to do pretty trivial.

Steve

Link to comment
Share on other sites

This is the line you need: cmd /c If not exist "c:Folder_1" (explorer.exe c:Folder_2), else (explorer.exe c:Folder_1)

Placed in a text field, use the Send Message referencing the field.

You need two Global text fields: a Global Text field to hold a single ". and the other global to set up the cmd command. The SetField calculation would look like this:

"cmd /c If not exist " & _Quote & "c:Folder_1" & _Quote & " (explorer.exe c:Folder_2), else (explorer.exe c:Folder_1)"

Your script would be:

Set Field [_Command]["cmd /c If not exist " & _Quote & "c:Folder_1" & _Quote & " (explorer.exe c:Folder_2), else (explorer.exe c:Folder_1)"]

Send Message [_Command]

What you are doing here is creating a Batch file on a single command line and running that batch file (or command file if you like). This method can be used for a lot of things in Windows - you just have to test for each Windows version, the syntax is veeerrry picky. I did the attached file on W2K - I did not have time to test it on XP.

Hope it helps...

OpenFolder.zip

Link to comment
Share on other sites

DykstrL,

It works but whew!... you were right when you say the syntax must be dead on. I spent about an hour working on the syntax of this one line. The matter was further complicated because the file path had a space in it so I had to surround the path name with quotes but it works like gang-busters!

Thank you sir.

Link to comment
Share on other sites

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