Jump to content
philipcaplan

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?

Share this post


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.

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


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

Share this post


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?

 

Share this post


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!!!!!

Share this post


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).

 

Share this post


Link to post
Share on other sites

Thanks.

file:$filePath was all it needed. Now it works.

Much appreciated.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.