cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
Choose Language Hide Translation Bar
TheSource
Level II

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!

4 REPLIES 4
jthi
Super User

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"));
-Jarmo
txnelson
Super User

Re: Rename File() and Copy File() both return 0

I verified that Jarmo's code works in JMP 14

Jim
TheSource
Level II

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?

jthi
Super User

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");

jthi_0-1742020880612.png

and you get this to log

This file could not be saved with the given name.

Unable to save file.
-Jarmo

Recommended Articles