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

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

Recommended Posts

Posted

I imported a script for launching an external file and I keep getting a "file not found" error when I try to use it. I guess I just don't know what I am doing.

THis is how the script looks:

If ["ImageFileName = """]

Show Message ["Please select a file to launch first."]

Exit Script

End if

Set Field ["ImageFileName", "External("TrFile-Launch",ImageFileName)"]

What I want to do is this:

I have a different JPG file associated with every record that I want the user to be able to open. For now I would like them to open it in Explorer. I have a field called ImageFileName that I put the name of the file. The file lives in the same director as the FMP file. (Someday Iwould like to have a viewer where they can zoom and pan on the image.)

Kathy

Posted

You're currently using the syntax "External("TrFile-Launch", ImageFileName)", however the TrFile-Launch function requires a full path or 'FileSpec' as its parameter, and you are supplying the filename on its own.

A more typical approach would be to precede the TrFile-Launch step with a step which gets the full path and places it in a temporary field, then calls the TrFile-Launch with a parameter which inserts the jpg filename into the path, thus:

Set Field ["gScript_Temp.txt", "External("TrFile-GetPathTo",

"-currentFileName |" & Status(CurrentFileName) &"|"& Status(CurrentFileSize))"]

Set Field ["gScriptResult.txt", "External("TrFile-Launch", Substitute(gScript_Temp.txt,

Status(CurrentFileName), ImageFileName)"]

However this will invoke the external call to the plug-in to launch the file into its associated application - which won't necessarily be the browser, as you are intending (depending on the configuration and installed software base of the computer you're working on).

To open the file in the default browser, you may in fact be better off using the Status(GetFilePath) function, followed by the Open URL script step to pass a composite URL for the jpg file directly to the browser.

Posted

<<To open the file in the default browser, you may in fact be better off using the Status(GetFilePath) function, followed by the Open URL script step to pass a composite URL for the jpg file directly to the browser.>>

Thanks Ray, any chance you can write the steps out for me so I know what to do? I haven't done any scripting, really. Ultimately I want to put this on a CD using the Web version because I can't afford Developer to make a runtime. So all the jpg files would be on the CD too and the user could click on button in each record and it would open the corresponding jpg file.

Kathy

Posted

Hi Kathy,

Well it's really much the same in principle as what I described for the Troi File external calls in the previous post. The key script steps to open the image file in the browser would run along the lines of:

Set Field ["gScript_Temp.txt", "Substitute(Status(CurrentFilePath), Status(CurrentFileName), ImageFileName)"]

Open URL ["gScript_Temp.txt"]

...And you'd presumably include the test to make sure that 'ImageFileName' was not empty, as outlined in your original post.

However this requires that you're working with FMPv5.5 or later, as the "Status(CurrentFilePath)" function was not available in earlier versions. Hope this is enough to get you moving.

Posted

Sorry, this is just too much over my head I guess. What is gscript_temp.txt? Is that a file that I need or have? and how can I put the file name in there if it is pulled from the ImageFileName field? I don't mean to be ignorant, the light just hasn't gone on yet.

I appreciate your help.

Posted

"gscript_temp.txt" is a global field set up to temporarily hold the substituted version of Image File Name, I assume. It is a convention to place a lowercase "g" in front of the names of global fields. You will have to create and define this field in your database (be sure to set results type to "text"!.) The Set Field step outlined above will insert the results of the substitution into this new global field without you doing anything further. Then the Open URL step will use this info to, well, open the URL.

Steve Brown

Posted

One more question. Do I need to have fields called CurrentFilePath and CNxgjntFilename? If so, what is the difference b/w CurrentFileName and ImageFileName. ImageFileName is the field where I put the filename. What would I put in these other fields. (I need a good book on basic scripting).

Posted

Hi,

CurrentFilePath and CurrentFileName are not names of fields, they are paramters for the Status( ) function, which cause it to return to full path to the current database file (in URL format) and the full name of the current database file (including the file type extension) respectively.

The only fields you need are your existing ImageFileName field, plus the new global text field that I called gScript_Temp.txt (without explaining why... sorry!). What is happening, as Steve says, is that the Status(CurrentFilePath) function is getting the URL path to your database, and the Substitute( ) function is putting the file name from ImageFileName into it in place of the name of the current database.

The result, which will be the full URL path to your jpg image, will then be waiting in the gScript_Temp.txt field, where it can be picked up by the next step (Open URL ["gScript_Temp.txt "] ).

Posted

BTW, although there are some books around on scripting, a number of which you'll find recommended on various threads on the forum, you will also find a mine of reference information in the online help that comes with FileMaker.

For instance of you look up 'status functions' in the online index, you get a full list of the four dozen or so parameters, each of which leads to a description of what that function/parameter combination does. You may not find everything you need there, but it is nevertheless often a good place to start.

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