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

How do I use an existing script from within a script

I have a script right now that acheives the effect I want, but I had to do it in a messy way and I'm hoping someone in the community can recommend a better way.  My script allows me to select a csv file, then it cleans up the data and creates a new nicely formatted jump table.  I also add a dashboard to that table.  The way I do it is shown below.  I take my table reference and I add a new script and I paste the dashboard script that I've created elsewhere within the parenthesis of the New Script command.  This works, but the problem is that the dashboard script is so big and so messy and changes so often that I have to constantly update my main script.  What I'd rather do is save off my dashboard script separately and then load it.  In other words something like this:

 

dt << New Script(
"Dashboard",
Load("C:\jmpfiles\MySavedOffDashboardScript.jsl")
);

What I actually implemented (with ellipses hiding the messy dashboard details):

 

dt << New Script(
"Dashboard",
JMP App(
Set Name( "Dashboard" ),
//...the rest of the messy script here...
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
David_Burnham
Super User (Alumni)

Re: How do I use an existing script from within a script

The way you use it is exactly as you described - juste use Include instead of Load.  You don't need the parse message because when you run the table script you want to run the contents of the include file.  If the table hasn't been saved then you will need to provide an absolute path rather than a relative path to the include file.

-Dave

View solution in original post

7 REPLIES 7
David_Burnham
Super User (Alumni)

Re: How do I use an existing script from within a script

The function that you want to "Load" the script is the Include function.

-Dave

Re: How do I use an existing script from within a script

I read up on the include function and I think you're right, but I'm still unclear exactly how to use it.  I don't want to run the script.  Rather I need to get a handle to the loaded script so I can add it to my table.  I tried the below but that didn't work.

 

subsetDt << New Script(
"Dashboard",
Include( "StudyFactsDashboard.jsl", <<Parse Only )

);

David_Burnham
Super User (Alumni)

Re: How do I use an existing script from within a script

The contents of the script shouldn't run until launched as a table script. Try this:

dt = New Table( "test",
	New Column( "Column 1")
);


dt << new script("test",
	show("Here");
);
-Dave

Re: How do I use an existing script from within a script

The problem wasn't that it ran.  It just didn't load the script into the table

David_Burnham
Super User (Alumni)

Re: How do I use an existing script from within a script

It doen't physically copy the contents of the include file - the table script will say "Include ... " but when run JMP will reference that file and execute the contents.

-Dave
David_Burnham
Super User (Alumni)

Re: How do I use an existing script from within a script

The way you use it is exactly as you described - juste use Include instead of Load.  You don't need the parse message because when you run the table script you want to run the contents of the include file.  If the table hasn't been saved then you will need to provide an absolute path rather than a relative path to the include file.

-Dave

Re: How do I use an existing script from within a script

That worked.  The key was to have the full path.  Also you're right, I didn't need the parse only keyword.

 

I really appreciate it!  My script is getting really slick and saving me a bunch of work.