cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
h_lazar
Level I

using choose function to run different scripts

I am not sure this is possible, it does not seem to be working. I have written three different scripts to manipulate a data table and then journal a bunch of plots. The scripts are quite involved but fairly similar. However, I have them written in separate files. Then I wrote another script to create a new window with a radio box option to choose which script to run. I am using the choose conditional function to run the appropriate script. However, nothing seems to be happening. Are there any ideas where I may be going wrong? Is this a namespace thing because I have stayed away from this complicated subject?

thanks in advance

H

Clear Symbols();

//dialog for fitting options

dlg = New Window( "Fit By ...",

      V List Box(

            Panel Box( " choose an option: ",

                  rad1 = Radio Box( {"option1", "option2", "option3"} )

            ),

            Text Box( " " ),

            H List Box(

                  bok = Button Box( "ok",

                        fit = rad1 << get;

                        dlg << close window;

                  ),

                  Text Box( " " ),

                  bcancel = Button Box( "cancel", dlg << close window )

            ),

            Text Box( " " )

      )

);

If( !Is Missing( fit ),

      Choose( fit,

//option 1

            Include( "script1.jsl" ),

//option 2

            Include( "script2.jsl" ),

//option 3

            Include( "script3.jsl" ),

      )

);

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: using choose function to run different scripts

You have a modeless dialog box, which will happily execute all commands after the new window() command while you are looking at the dialog box.

Try using a modal dialog box instead:

dlg = New Window( "Fit By ...", << modal,

.

.

.

View solution in original post

6 REPLIES 6
pmroz
Super User

Re: using choose function to run different scripts

You have a modeless dialog box, which will happily execute all commands after the new window() command while you are looking at the dialog box.

Try using a modal dialog box instead:

dlg = New Window( "Fit By ...", << modal,

.

.

.

h_lazar
Level I

Re: using choose function to run different scripts

That was it. Thanks for answering my simple and inexperienced question.

H

saneal
Level III

Re: using choose function to run different scripts

Hello! I am using this script as a basis for my own. I can get my prompt window to pop up and both the OK and CANCEL buttons seem to work but the last portion here:

If( !Is Missing ( scriptselection ),
	Choose (scriptselection, 
		//Run Rg Script
			Include("Rg Script.jsl"),
		//Run Camtek Script
			Include("Camtek.jsl"),
		//Run Probe 1/3 Script
			Include("Probe 1/3.jsl")
		)
);

Can you speak a bit more on this? I would like to open and immediately run these files from a location in my computer. Is this the correct approach? Or do I need to specify location more? (If so how do I do this?) Thank you!

saneal
Level III

Re: using choose function to run different scripts

Note that these are longer scripts (500-1000 lines each) and I would like to open them if selected by the radiobox after OK is clicked.
jthi
Super User

Re: using choose function to run different scripts

This is fairly old topic so syntax might have gone through some changes. Here is an example which should give you an idea how to develop your script:

Names Default To Here(1);
rb_selections = {"timeAnnouncer", "triangleProbability", "JMPStarter"};
scriptFolder = "C:\Program Files\SAS\JMP\15\Samples\Scripts\";

If(
	nw = New Window("Dialog() example",
		<<Modal,
		<<Return Result,
		V List Box(
			Panel Box("choose an option: ", rb = Radio Box(rb_selections)),
			H List Box(Button Box("OK", rbval = rb << get;), Button Box("Cancel"))
		)
	);
	nw["button"] == 1,
	Choose(rbval,
		Include(scriptFolder || "timeAnnouncer.jsl"),
		Include(scriptFolder || "triangleProbability.jsl"),
		Include(scriptFolder || "JMPStarter.jsl");
	),
	Print("CANCEL");
);

Also see Scripting Index directly from JMP and JMP15 Scripting Guide 

 

-Jarmo
saneal
Level III

Re: using choose function to run different scripts

Wow Jthi! You hit the nail on the head here. Thank you so much. Works like a charm. I appreciate it.