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

With relative paths: 1. Export to desktop, 2. Export to same directory.


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

Recommended Posts

Posted

Thanks to the help file (not always do I find the perfect solution there!), I have figured out how to automate an export:

Sort [Restore, No dialog]

Export Records [Restore, No dialog, "Word List.txt"]

However, the path is to the desktop and it's an absolute path which will crash if I move the solution or if during next OS install, I do something different and desktop has slightly different path. I need a relative path to the desktop. I need this script to work no matter what happens down the line.

Also, I found this syntax on this forum message (http://fmforums.com/forum/showtopic.php?tid/210231/post/new/#NEW):

Set Variable [ $fullpath; Value:Get ( DesktopPath ) & $filename ]

These variables look like AutoIt ones (which I'm very familiar with). "DesktopPath" would make the script very flexible as it means to me that it always will go to the desktop no matter the path (?).

However, I'm a real dunce at modifying new scripts and I don't know how to incorporate that type of functionality to my script effort above ... I've searched through many "export" posts in this forum but haven't found anything to help me with this.

Also, lastly, though a relative desktop destination is very good, I'd also like to know how to get the export to the same folder the Filemaker solution is in, again using a variable or whatever, that can handle a relative path. In AutoIt, when I want something done within the same folder that the script is in, we use this syntax:

@ScriptDir

Is there a way to get an automated script to export the "Word List.txt" to the desktop and to the same folder? I can then see which actually is best to work with and keep that in the solution, folder or desktop ... But having both options available would be good.

Thank you! :

Posted

Variables start with a $ symbol and have scope only inside the script.

Use Get(DocumentsPath) to get path to documents folder.

Use Get(DesktopPath) to get path to desktop folder.

Use Get(FilePath) to get the path to the currently active database file.

So you would just use Set Variable $fullpath; Value:Get ( DesktopPath ) & "Word list" ]

& operator above concactenates (joins) two strings.

The export script would then use $fullpath as the filename

You must use a 'variable' and not a 'field' as the Filename for an export.

You should be able to do what you want with the Get functions above.

Posted

Hi! Um, I have FMP6. I've been googling and googling since I couldn't figure out how to deal with this Set Variable, but here's what I found:

2009-08-02 10:03:51 (http://filemakertoday.com/com/showthread.php?t=19223)

set variable equivalent?

Variables were introduced in FM8.0. For earlier versions, use global fields.

-----------------------------

2009-08-02 10:06:48 (http://db.tidbits.com/article/8254)

Enter script variables. In FileMaker 8, you can define a local script variable right in the script - say, "$contactID" - using the new Set Variable script step, then access that variable later in the script in a calculation formula, the same way you would have accessed a global field. One advantage of variables is that they can be defined on the fly; to define a global field, it was necessary to exit the script editor, enter the Define Fields dialog, and define a new field. Another advantage of script variables is that they can be either local or global. Global fields were always global, meaning that they could be accessed from any table in the same file, and values stayed set until replaced. Global variables work in much the same way, but local variables are cleared at the end of the script in which they are defined.

-----------------------------

What would be the v6 equivalent, pls, anyone know? (And there is no option to upgrade, btw . I just know many might be itching to say that ... .)

Thanks. :

Posted

I am having such a hard time of this. Anyone remember FMP6? I have found quite a few references to Get(Desktop) but nothing I've tried works. The most common error I get is this:

"Either an operator was omitted, this function

cannot be found, or "(" was not expected here."

My script is, so far, as follows:

I was advised to use this:

Set Variable $fullpath; Value:Get ( DesktopPath ) & "Word list" ]

But "Set Variable" is a feature of FMP8 and above. Pls, pls, pls, can someone help me? My script so far is quite good as it performs the export with no user intervention. As mentioned above, that script is this:

Sort [Restore, No dialog]

Export Records [Restore, No dialog, "Word List.txt"]

It may be that Set Variable is Set Field in FMP6, though I'm not absolutely sure.

When I click on Set Field as script step #2, it prompts me for a field. I have absolutely no idea if this should even have to know that information but if it does, how would this work, pls? I am completely lost, I see and nothing comes up that is of help to me re exporting to a pre-determined filepath + name automatically.

Thanks in advance.

Cheers.

Posted (edited)

First, sorry, I didn't check your version when I initially responded. I don't think you can do this in FMP6.

The only recourse I can think of is to have the script map an unused drive to the path you want, then save to a fixed filename on that volume. For instance, the script would export to R:word.txt. At least, I think FMP6 included send event script step?

Before issuing that command you would fire off a DOS command to define R: (or some other high, unused drive letter) using subst (maps a drive to local filesystem). You can then define R: use dos environment variables such as %homedrive% and %homepath%

The second subst with a /D switch deletes the R: assignment. Change CMD /K to CMD /C after debugging to close DOS windows. Pause is to allow drive time to be mapped before attempting to write to it.

send event ["aevt","odoc","CMD /K" & """ & "subst R: %homedrive%%homepath%Documents" & """]

Pause 2 sec

Filemaker Export to: [filewin:/R:/word.txt]

send event ["aevt","odoc","CMD /K" & """ & "subst R: /D" & """]

This isn't elegant but should allow you to save a file anywhere from an automated script.

Also, in later versions of Filemaker at least, the default path is documents, so just exporting to:

file:word.txt

will do the trick without any VBS. Unfortunately, due to FM's non-standard filespec conventions, the %homedrive% symbol won't work in the export command itself as it will with any other program.

Edited by Guest

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