Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
mann
Level II

Saving to disk as hidden or read-only

I have .jsl script that pulls data from a SQL server and saves it as .jmp & .xlsx.  The .jmp file is so I can look at the data without waiting for the SQL query. The .xlsx file is so a different .xlsm file can read it (also without waiting) and run other macros as needed.

However, some people without JMP open the .xlsx file to read the data.  And then they don't close it - which means the .jsl cannot save a new updated copy (every hour) -- which means the .xlsm is using stale data.  

I want the .jsl file to save a hidden copy (for the .xlsm file) and a visible copy (for the humans), but it seems having the .jsl save over a hidden file is forbidden.  As is, unsurprisingly, saving over a read-only file. 

Can I have .jsl save over a hidden file? Can I use .jsl to unhide the file first?  Is there a much simpler solution I am overlooking?  Thanks in advance.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Craige_Hales
Staff (Retired)

Re: Saving to disk as hidden or read-only

two snippets that might be useful

// make read only: attrib.exe +R <Path>
txt=Run Program(executable("attrib.exe"),options({"+R","\!""||file||"\!""}),readfunction("text"));
if(txt!="",show(txt));

and

// make NOT read only: attrib.exe -R <Path>
txt=Run Program(executable("attrib.exe"),options({"-R","\!""||convertfilepath(file,windows)||"\!""}),readfunction("text"));
if(txt!="",show(txt));

You should probably use the convertFilePath(... , windows) on the top one as well; the command line program attrib will be expecting a windows style name. I think the code I grabbed these from knows the top one is already OK. Attrib prints nothing when it works. The if(...show...) is for debugging bad path names. The doc says attrib can set and clear the hidden attribute as well.

I think read-only is the way to go; I suspect that will make other programs not lock you out.

Craige

View solution in original post

2 REPLIES 2
Highlighted
Craige_Hales
Staff (Retired)

Re: Saving to disk as hidden or read-only

two snippets that might be useful

// make read only: attrib.exe +R <Path>
txt=Run Program(executable("attrib.exe"),options({"+R","\!""||file||"\!""}),readfunction("text"));
if(txt!="",show(txt));

and

// make NOT read only: attrib.exe -R <Path>
txt=Run Program(executable("attrib.exe"),options({"-R","\!""||convertfilepath(file,windows)||"\!""}),readfunction("text"));
if(txt!="",show(txt));

You should probably use the convertFilePath(... , windows) on the top one as well; the command line program attrib will be expecting a windows style name. I think the code I grabbed these from knows the top one is already OK. Attrib prints nothing when it works. The if(...show...) is for debugging bad path names. The doc says attrib can set and clear the hidden attribute as well.

I think read-only is the way to go; I suspect that will make other programs not lock you out.

Craige

View solution in original post

Highlighted
mann
Level II

Re: Saving to disk as hidden or read-only

Thanks Craige, This opens some neat doorways.
Article Labels

    There are no labels assigned to this post.