cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
mann
Level III

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
Craige_Hales
Super User

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

3 REPLIES 3
Craige_Hales
Super User

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
Devin
Level I

Re: Saving to disk as hidden or read-only

Hey Craig, or audience, I'm a true HACK at jsl, if the excel table I want to save as read-only (over a currently opened or hidden *.xlsx file) is at \\Server\Engineering\Project\qbert.xlsx, how can I apply the script above? In the example, is txt the table of interest? And if so, what are the terms text, attrib.exe, and file ? Are those jsl functions or references to the table I'm manipulating?  Thanks in advance!!  -Devin

mann
Level III

Re: Saving to disk as hidden or read-only

Thanks Craige, This opens some neat doorways.