Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
kadiew
Level II

Can't capture listbox selection in application builder

Hi everyone,

 

I'm new to jmp and I'm trying to use the application builder. I have a launch module with a listbox and two values, "ER" and "IL". Once a user presses a button, I'd like to be able to capture which selection(s) they chose, if any. 

For some reason, when I print "AnalysisSelected" to the text box, the text that appears is "List". It works if I choose to only print "AnalysisSelected[1]" to the text box, but I want to be able to loop through the selected analyses and take proper action once I pass the variable to the GraphBuilder...

 

Thanks in advance!!

kadiewright_0-1582816864644.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
cwillden
Super User

Re: Can't capture listbox selection in application builder

A list box is container for any kind of display boxes to display them in sequence vertically or horizontally.  Is AnalysisTypes a radio box?

JSL as far as I know does not use the "this"/"self"/"me" convention of object-oriented languages, so that part of your script is not doing anything.

 

If AnalysisTypes is a radio box and Error Text is a textbox, your function should look like this:

RunAnalysis = function({},
	AnalysisSelected = AnalysisTypes << Get Selected;
	//show(AnalysisSelected);
	Error Text << Set Text(AnalysisSelected);
);

The "show(AnalysisSelected)" line is commented out, but you can uncomment that line and see what the value of that variable is in the log.  That is a really handy function to use for debugging.

 

I attached a working example in App Builder using this script.

 

You said you are new to JMP, and I would recommend taking the time to learn the fundamentals of JSL before jumping right into App Builder.  That's a lot to try to chew for a new user.  Jump Into JMP Scripting by Wendy Murphrey and Rosemary Lucas is a fantastic book that I would highly recommend purchasing if you plan to use JSL a lot.  I wrote a gentle introduction to Application Builder a couple years ago that you may also find helpful: https://community.jmp.com/t5/Discussions/Gentle-Introduction-to-Application-Builder/m-p/49629#M28232

-- Cameron Willden

View solution in original post

2 REPLIES 2
Highlighted
cwillden
Super User

Re: Can't capture listbox selection in application builder

A list box is container for any kind of display boxes to display them in sequence vertically or horizontally.  Is AnalysisTypes a radio box?

JSL as far as I know does not use the "this"/"self"/"me" convention of object-oriented languages, so that part of your script is not doing anything.

 

If AnalysisTypes is a radio box and Error Text is a textbox, your function should look like this:

RunAnalysis = function({},
	AnalysisSelected = AnalysisTypes << Get Selected;
	//show(AnalysisSelected);
	Error Text << Set Text(AnalysisSelected);
);

The "show(AnalysisSelected)" line is commented out, but you can uncomment that line and see what the value of that variable is in the log.  That is a really handy function to use for debugging.

 

I attached a working example in App Builder using this script.

 

You said you are new to JMP, and I would recommend taking the time to learn the fundamentals of JSL before jumping right into App Builder.  That's a lot to try to chew for a new user.  Jump Into JMP Scripting by Wendy Murphrey and Rosemary Lucas is a fantastic book that I would highly recommend purchasing if you plan to use JSL a lot.  I wrote a gentle introduction to Application Builder a couple years ago that you may also find helpful: https://community.jmp.com/t5/Discussions/Gentle-Introduction-to-Application-Builder/m-p/49629#M28232

-- Cameron Willden

View solution in original post

Highlighted
pmroz
Super User

Re: Can't capture listbox selection in application builder

You're close.  A few notes:

  • list(AnalysisSelected) does not do anything but create {AnalysisSelected}.  
  • Get Selected for a listbox returns a list
  • If you're trying to put a number into a text box you need to convert it to a character with char().

Try this code:

analysis_list = analysistypes << get selected;
var = nitems(analysis_list);
if (var > 0,
	analysisselected = analysis_list[1];	// Assumes you're restricting # choices to 1
	,
	error text << set text(char(var));
);

 

Article Labels

    There are no labels assigned to this post.