- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Rename File() and Copy File() both return 0
Hi,
I have a need to save a small data table as a csv but with an alternate file extension (*.blkl rather than *.csv). The Save As() function doesn't seem to allow for such a provision as near as I can tell so instead of saving the file with my desired filename I save it as *.blkl.csv and then attempt to either directly rename that file to the desired name or perform a copy+delete sequence to get the desired output file.
My script will happily save the file but both the Rename File() and Copy File() functions both return 0 indicating that the operation failed with no other information given. How can I go about debugging the failed file operations?
JMP 14.3.0 (64 bit)
Windows 11 Enterprise (64 bit)
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Rename File() and Copy File() both return 0
How are you trying to do it? For me this works fine (using JMP18)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Save("$TEMP/bigclass.csv");
Show(File Exists("$TEMP/bigclass.csv"), File Exists("$TEMP/bigclass.blkl"));
Rename File("$TEMP/bigclass.csv", "bigclass.blkl");
Show(File Exists("$TEMP/bigclass.csv"), File Exists("$TEMP/bigclass.blkl"));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Rename File() and Copy File() both return 0
I verified that Jarmo's code works in JMP 14
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Rename File() and Copy File() both return 0
I found the issue. Both Rename File() and Copy File() will fail if the file exists so they aren't independently suitable for overwrite operations. I've added a delete-pre-check and it's all running smoothly now.
For future reference, do jsl library functions report this sort of debug information anywhere or is it just pass/fail status?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Rename File() and Copy File() both return 0
Some functions might give you some more feedback. For example if you try to overwrite data table which is already open
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Save("$TEMP/bigclass_test.jmp");
dt1 = Open("$SAMPLE_DATA/Big Class Families.jmp");
dt1 << Save("$TEMP/bigclass_test.jmp");
and you get this to log
This file could not be saved with the given name.
Unable to save file.