Jump to content

How to Export Record to file with filename from a field


Recommended Posts

I have a Script that uses "Export Records" to export a file to the following path:

file:../../../../Desktop/OUTPUT/Untitled.tab

How do I get 'Untitled' replaced by the contents of a field in my Table?

Link to post
Share on other sites

Set a variable to:

Get (DesktopPath) & "OUTPUT/" & YourTable::YourField & ".tab"

then use this variable as the output file path in the Export Records > Specify output file dialog.

 

Link to post
Share on other sites
Posted (edited)

Thank you, comment.

I used the "set variable" as follows, and created the following script:
image.png.60d94d7b89100e106dacfcab60d12578.png

The script runs but gave the following error. The filename is valid (I checked by copying a file into OUTPUT and changing its name to match the value of the variable).

image.png.49d2064fb66085bb83980f3585579093.png

Please can you advise what I have done wrong!!
(Please ignore any image below here, saying ".tab". I have tried to delete it, but it keeps reappearing!!

image.png

Edited by philipcaplan
extra image was included, had to be deleted
Link to post
Share on other sites
Posted (edited)

Then I don't know. I've made a simple test file that works for me. See if it works for you, so that we can tell if it's something in your file or in your system.

 

ExportTest.fmp12

Edited by comment
Link to post
Share on other sites

I have run your test script, and it works.

I tried copying-and-pasting from your script into a new script in my FMPro as follows:
image.png.b346427d4e12220c07d4fc0097d7dada.png

but I still got a failed result.

Any other thoughts?

image.png

image.png

Link to post
Share on other sites

Not really. I am ignoring your last attempt, which is obviously wrong (there shouldn't be any escaped quotes in the filepath calculation). The only thing that comes to mind is that your field contains an invalid filename. I am not able to verify this through a screenshot, but perhaps there are some invisible characters?

 

Link to post
Share on other sites

I thought that maybe it is the filename that is causing the problem, so I tried using a different field in my table whose content was just PS501 but it didn't help. I got:  "PS501.txt"  could not be created on this disk etctetc.

But if I changed $filePath to xxxfilePath in the Export Records script step, the file got created with filename xxxfilePath.

Unfortunately, that's not QUITE what I need!!!!  Perhaps I'll have to write the files that way by script, and then rename them by hand! A temporary solution, but not very useful!

BTW  the extra images are ones I tried to delete. "edit" seems to allow me to edit my message shortly after hitting "Submit Reply" but when the message reappears the deleted image is not deleted!!!!!

Link to post
Share on other sites

You have this as the output file path:

file:../../../../Desktop/OUTPUT/$filePath

You should have only:

file:$filePath

or:

$filePath

The path to the desktop and the OUTPUT folder is already included in the $filePath variable (use Show Custom Dialog to see its exact contents).

 

Link to post
Share on other sites

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.