cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
pmroz
Super User

Create Table and then Save it in JSL

Hello JMPers,

I'm creating a dataset by retrieving data from Oracle. Immediately after getting the data I want to save it, using a name chosen by the user. The JSL looks like this:

dt = open database(dsn_string, sql_statement, "MedDRA Categories");
dt << save();

However, I don't get the File > Save dialog. Instead it just tries to save the file (somewhere?) and the log shows the error messages

The file cannot be opened for writing, opening for reading only.
This file could not be saved with the given name.

Thanks!
1 ACCEPTED SOLUTION

Accepted Solutions
mpb
mpb
Level VII

Re: Create Table and then Save it in JSL

I didn't see it in the 8.0.2 docs but fooled around a bit and found that this brings up a save dialog:

dt << save("");

The docs do say that dt << save() saves using the current table name.

I should add that I tried this using an Excel file as my "database" via ODBC. Not sure that the save thing has anything to do with how the table was created although I must say that I did not get the error messages you saw using save() and the file was successfully saved;

Michael

View solution in original post

6 REPLIES 6
mpb
mpb
Level VII

Re: Create Table and then Save it in JSL

I didn't see it in the 8.0.2 docs but fooled around a bit and found that this brings up a save dialog:

dt << save("");

The docs do say that dt << save() saves using the current table name.

I should add that I tried this using an Excel file as my "database" via ODBC. Not sure that the save thing has anything to do with how the table was created although I must say that I did not get the error messages you saw using save() and the file was successfully saved;

Michael
pmroz
Super User

Re: Create Table and then Save it in JSL

That worked great. I don't think I would have figured that little trick out. Thanks a lot Michael!
pmroz
Super User

Re: Create Table and then Save it in JSL

New wrinkle on this problem:

I'm creating some XML text and would like to save it to an XML file. I'm creating a default output filename, and would like the user to have a little control over the process. I want something like what happens when you use SAVE(""), only I want to provide a default filename, and the extension must be XML.

It looks like the PICK FILE function can do the job:

path = pick file(, , , , , )

Prompts the user with an Open window, returning the pathname of the chosen file. The filterList argument is a list of strings of the form: "Label|suffix1;suffix2;...". The first filter argument specifies which filter is initially shown. The fifth argument indicates whether the window should function as a save (saveFlag = 1) or open (safeFlag = 0) window. The final argument specifies the file that is initially selected.

However the saveflag doesn't appear to work as advertised:

xml_default_file = "myfile.xml";
xml_file_path = pick file("Save the XML file", "", {"XML File|xml", "All Files|*"},
1, 1, xml_file);

save text file(xml_file_path, xml_text);

I get errors saying the file myfile.xml does not exist.

Thanks for your help!
Peter
Jeff_Perkinson
Community Manager Community Manager

Re: Create Table and then Save it in JSL

Hi Peter,

I just tried your example and it looks like there might be a bug here.

Please send a note to tech support (support@jmp.com) and let them have a look.

Thanks!

Jeff
-Jeff
mpb
mpb
Level VII

Re: Create Table and then Save it in JSL

Looks like the designators for open and save are reversed. Ie, 1 wants to open and 0 wants to save. The following does work but shouldn't if the function is fixed to operate as documented (or maybe the docs should be changed?):

xml_text = "Some text to be saved";
xml_default_file = "myfile.xml";
xml_file_path = Pick File(
"Save the XML file",
"",
{"XML File|xml", "All Files|*"},
1,
0,
xml_default_file
);

Save Text File( xml_file_path, xml_text );
pmroz
Super User

Re: Create Table and then Save it in JSL

Works like a charm. Thanks for poking around on it. I'll notify tech support.

Regards,
Peter