philipcaplan 2 Posted May 23, 2020 Share Posted May 23, 2020 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
comment 1,775 Posted May 23, 2020 Share Posted May 23, 2020 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
philipcaplan 2 Posted May 23, 2020 Author Share Posted May 23, 2020 (edited) Thank you, comment. I used the "set variable" as follows, and created the following script: 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). 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!! Edited May 23, 2020 by philipcaplan extra image was included, had to be deleted Link to post Share on other sites
comment 1,775 Posted May 23, 2020 Share Posted May 23, 2020 Do you have a folder named OUTPUT on the desktop? Link to post Share on other sites
philipcaplan 2 Posted May 23, 2020 Author Share Posted May 23, 2020 Yes. Link to post Share on other sites
comment 1,775 Posted May 23, 2020 Share Posted May 23, 2020 (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 May 23, 2020 by comment Link to post Share on other sites
philipcaplan 2 Posted May 23, 2020 Author Share Posted May 23, 2020 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: but I still got a failed result. Any other thoughts? Link to post Share on other sites
comment 1,775 Posted May 23, 2020 Share Posted May 23, 2020 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
philipcaplan 2 Posted May 23, 2020 Author Share Posted May 23, 2020 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
comment 1,775 Posted May 23, 2020 Share Posted May 23, 2020 Can you post a copy of your file, reduced to the minimum necessary to show the problem? Link to post Share on other sites
philipcaplan 2 Posted May 23, 2020 Author Share Posted May 23, 2020 Here is the entire file, all 328kb of it before zipping to 83kb..... PSEFER.fmp12.zip Link to post Share on other sites
comment 1,775 Posted May 23, 2020 Share Posted May 23, 2020 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
philipcaplan 2 Posted May 23, 2020 Author Share Posted May 23, 2020 Thanks. file:$filePath was all it needed. Now it works. Much appreciated. Link to post Share on other sites
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now