cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
baiyun
Level I

How to trigger a button to open "Save File Windows Explore" via JSL?

I am trying to get help from community members to see that if a "Save File Windows Explore" can be triggered as below screenshot after a button-clicking event? 

Is there anyone who has an idea? Thanks in advance. 

 

baiyun_1-1614578270791.png

 

 

 

 

6 REPLIES 6
jthi
Super User

Re: How to trigger a button to open "Save File Windows Explore" via JSL?

Seems like you cannot yet directly save .jrp through JSL Save charts as ".jrp" file in JSL but JMP16 will bring this possibility.

 

You could save it as text file with Save Text File and using empty path (it should open Save As menu). Save Text File returns the path to the saved file -> change saved file type from .txt (or something else) to .jrp with Rename File.

-Jarmo
baiyun
Level I

Re: How to trigger a button to open "Save File Windows Explore" via JSL?

Hi Jthi, 

 

Thanks for your solution. It works as you said, I will take it.

baiyun
Level I

Re: How to trigger a button to open "Save File Windows Explore" via JSL?

Hi  Jthi, 

 

I saved my file as text file with Save Text File and using an empty path (it should open Save As menu). Save Text File returns the path to the saved file -> change saved file type from .txt (or something else) to .csv with Rename File. But eventually, the file haven't been saved successfully. Do you know why? 

 

baiyun_0-1615435728929.png

 

jthi
Super User

Re: How to trigger a button to open "Save File Windows Explore" via JSL?

Something like this seemed to work fine for me:

Names Default To Here(1);
temp_text = "test text";
fileDirectory = "$TEMP/";
filename = "test";
Show(File Exists(fileDirectory||filename||".txt"));
newFilePath = Save Text File(fileDirectory||filename||".txt", temp_text);
Show(File Exists(newFilePath));
//If old .csv file exists remove before saving
If(File Exists(fileDirectory||filename||".csv"),
	Delete File(fileDirectory||filename||".csv")
);
c = Rename File(newFilePath, filename||".csv");
Show(File Exists(fileDirectory||filename||".csv"));
//Open("$TEMP/"); //run this row without first comment to open $TEMP path

Maybe adding debug writes/shows to your code can help you debug. Running script in parts might also help to see where the issue is (or using Debugger). If you have big files you also need to add wait(0) somewhere there.

 

 

-Jarmo
baiyun
Level I

Re: How to trigger a button to open "Save File Windows Explore" via JSL?

Thanks for your quick response. 

But if using the way you showed me, the user is not able to save files to any name or anywhere as they want? 

 

jthi
Super User

Re: How to trigger a button to open "Save File Windows Explore" via JSL?

It was showing that the idea should work.

 

Add additional prints, waits, stops and check what this does. It seemed to be working fine for me.

Names Default To Here(1);
temp_text = "aa,bb\!N1,2";
filePath = Save Text File("", temp_text);
Show(File Exists(filePath));

//replace .txt with .csv
csvPath = Substitute(filePath, ".txt", ".csv");
//If old .csv file exists remove before saving
If(File Exists(csvPath),
	Delete File(csvPath)
);

//get only csv file name
csvFileName = Word(-1, csvPath, "\/");
c = Rename File(filePath, csvFileName);
Show(File Exists(csvPath));
//Open(csvPath); 
-Jarmo