cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
jthi
Super User

Modal window, return result and Filter Col Selector/Col List Box

Does someone have an idea if I'm doing something wrong with New Window() <<modal and <<return result with Col List Boxes? Or is this possibly a bug or undocumented behaviour due to New Window(<<modal, << return result)) replacing Dialog() function?

 

I cannot get results from Filter Col Selector and Col List Boxes when using << return result and have to get values with <<on close, when button is pressed or set additional scripts to display boxes which would update values (which I wouldn't want to do and I don't want to use Column Dialog() either due to its lack of customisation).

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

nw = New Window("Split", Show Menu(0), Show Toolbars(0), <<Modal,
	<<Return Result,
	<<On Close(nw_result = Associative Array({"clb_by", "clb_split"}, Eval List({clb_by << get items, clb_split << get items})));
	V List Box( Align("right"),
		H List Box(
			teb = Text Edit Box("maybe this works"),
			Panel Box("", fcl = Filter Col Selector(Data Table(dt), all, nlines(10))),
			Panel Box("",
				H List Box(
					Spacer Box(size(0, 164)),
					Lineup Box(N Col(2),
						Button Box("Split By", clb_by << append(fcl << get selected)),
						clb_by = Col List Box(<<Modeling Type({"Nominal", "Ordinal"}), min items(1), nlines(4)),
						Button Box("Columns to split", clb_split << append(fcl << get selected)),
						clb_split = Col List Box(Data Table(dt), <<Set Data Type("Numeric"), min items(1), nlines(2)),

					)
				)
			)
		),
		H List Box(
			Button Box("OK", nw_result_btn = Associative Array({"clb_by", "clb_split"}, Eval List({clb_by << get items, clb_split << get items}))),
			Button Box("Cancel")
		)
	);
);

Show(nw, nw_result, nw_result_btn);

jthi_0-1637137847616.png

Return result(nw) will return empty lists, On Close(nw_result) and button (nw_result_btn) seems to get the values as I would expect.

 

nw = {teb = "maybe this works", fcl = Empty(), clb_by = {}, clb_split = {}, Button(1)};
nw_result = ["clb_by" => {"name", "sex"}, "clb_split" => {"weight", "height"}];
nw_result_btn = ["clb_by" => {"name", "sex"}, "clb_split" => {"weight", "height"}];

 

Not the first one with this problem.

-Jarmo
5 REPLIES 5

Re: Modal window, return result and Filter Col Selector/Col List Box

The << Return Result message causes the modal window to act like the old deprecated Dialog() function. The current 'values' in the display boxes are saved for you in the assigned variables. So myNEB = Number Edit Box( 42 ) in my script will result in the assignment of the current value to myNEB when I click OK to dismiss the window.

Craige_Hales
Super User

Re: Modal window, return result and Filter Col Selector/Col List Box

Agree, those boxes are not being as helpful as they should be. Somebody (at JMP) has to decide what each type of box should be returning. Since it can't return the box, some part(s) of the box's data have to be selected.

 

Edit: I sent JMP a note.

Craige

Re: Modal window, return result and Filter Col Selector/Col List Box

There are two other methods supported for the extraction of values from the window. Perhaps << Return Result is not the best choice for this case.]

 

JMP Help: Extract Values

jthi
Super User

Re: Modal window, return result and Filter Col Selector/Col List Box

I have two problems with the current << return result:

  1. It changes the modal to act like deprecated Dialog() function, but haven't used JMP long enough to have used Dialog(), so I don't really know the behavior (and not really sure if i like to start going through all deprecated functions to understand what current ones do). Quickly checking JMP16 scripting guide's comparison between Dialog and << return result new window... I'm happy that the dialog is gone an I can use just New window (with or without << return result).
  2. Other is that I would like to have elements behave similarly. Of course this isn't as simple because display boxes will return different values depending what message you use( << get, << get selected, << get text, << get items, << get selected indices...). So this maybe would have to be implemented into the display box so user can choose the "default return"?

I really like using << return result for quick modals, but I might (try to) go back to one of the other methods which will always work, so I can keep my code similar between different modals (simple and complicated).

 

Some further testing, return results seems to return selected values in Col List Boxes (but not for filter col box):

View more...
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

//1. use << return result
nw = New Window("test window", << modal, << return result,
	fls = Filter Col Selector(dt, all, << set selected(1)),
	clb = Col List Box(dt, all, << set selected(2)),
	cb = combo box({"selection1", "selection2"}),
	rb = Radio Box({"a", "b", "c"}),
	teb = Text Edit Box("teb"),
	neb = Number edit box(10),
);
show(nw);

//2. get values in button
aa_results = Associative Array();
nw = New Window("test window", << modal, << return result,
	fls = Filter Col Selector(dt, all, << set selected(1)),
	clb = Col List Box(dt, all, << set selected(2)),
	cb = combo box({"selection1", "selection2"}),
	rb = Radio Box({"a", "b", "c"}),
	teb = Text Edit Box("teb"),
	neb = Number edit box(10),
	Button Box("OK",
		aa_results["fls"] = fls << Get selected;
		aa_results["clb"] = clb << get items;
		aa_results["cb"] =  cb << get;
		aa_results["rb"] = rb << get;
		aa_results["teb"] = teb << get text;
		aa_results["neb"] = neb << get;
	);
);
If(nw["Button"] == 1,
	show(aa_results);
);


//3. get values during on close
aa_results = Associative Array();
nw = New Window("test window", << modal, << return result,
	<< on close(
		aa_results["fls"] = fls << Get selected;
		aa_results["clb"] = clb << get items;
		aa_results["cb"] =  cb << get;
		aa_results["rb"] = rb << get;
		aa_results["teb"] = teb << get text;
		aa_results["neb"] = neb << get;
	),
	fls = Filter Col Selector(dt, all, << set selected(1)),
	clb = Col List Box(dt, all, << set selected(2)),
	cb = combo box({"selection1", "selection2"}),
	rb = Radio Box({"a", "b", "c"}),
	teb = Text Edit Box("teb"),
	neb = Number edit box(10),
);
If(nw["Button"] == 1,
	show(aa_results);
);

//4. would be to set script to each of elements, but I prefer other methods
//5. create wrapper with onclose and return result?

/*

//some of the ways to get values from different display boxes
nw = New Window("test window",
	fls = Filter Col Selector(dt, all, << set selected(1)),
	clb = Col List Box(dt, all, << set selected(2)),
	cb = combo box({"selection1", "selection2"}),
	rb = Radio Box({"a", "b", "c"}),
	teb = Text Edit Box("teb"),
	neb = Number edit box(10),
);
show(nw);


fls << Get selected;
clb << get items; clb << get selected; clb << Get Selected Indices;
cb << get; cb << get selected;
rb << get; rb << Get Selected;
teb << get text;
neb << get; neb << get text;

For now I think I will continue with either getting values with Button Box() or getting values with << On Close().

-Jarmo
pmroz
Super User

Re: Modal window, return result and Filter Col Selector/Col List Box

I always put result assignments into the script section of an OK button box.  More control that way.