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
Level I

Button Box Created By Function References Incorrect Variable

My goal is to create a GUI which is used to set limits against parameters for tests I am running. The GUI will have three different sections and each section references a different list available for setting limits. Each section is contained within an outline box where a function "addParam" is called. This function adds a new h List Row to the outline box which contains three items: A delete button, a combo box for selecting parameters, and an "Add Limit"  for adding one or more limits onto the same parameter. When "Add Limit" is pressed it references a list that was passed into the function showing the available stats for that given table.

My problem is: When I add limits in one outline box, and move onto editing a different outline box, if I try to back track to a previous parameter row in the last outline box then the add limit button references the stat list from the second outline box and not the first; however, if I "Add Parameter" of the first outlinebox again then the list corrects itself to the proper stat list.


addParam = function({parameter, statList},
	selectParam = comboBox(parameter);
	keepStats = statList; //If I don't create "keepStats" then statList cannot be referenced after function is called
	//Deletes row
	dltRow = buttonBox("Delete", <<setFunction(Function({this}, (this<<Parent) << Delete )));
	//Button Box to add a row which holds limit setting information
	addRow = buttonBox("Add Row",
				(this<<Parent) << append(comboBox(keepStats));
				(this<<Parent) << append(textEditBox("Lower Limit"));
				(this<<Parent) << append(textEditBox("Upper Limit"));
	//hListBox to hold parameter and associated limits
	returnRow = hListBox(dltRow, selectParam, addRow);

//Parameters to set limits for
parameterList = {"Parameter1", "Parameter2", "Parameter3"};

//Stats used for limit setting of parameters
statListOne = {"Mean", "Median"};
statListTwo = {"Max", "Min"};
statListThree = {"Slope", "Intercept"};

//Outline boxes for different stat table types
statTblOne = outlineBox("Stat One Table",
	buttonBox("Add Parameter",
		newParam = addParam(parameterList, statListOne);
		statTblOne << append(newParam);

statTblTwo = outlineBox("Stat Two Table",
	buttonBox("Add Parameter",
		newParam = addParam(parameterList, statListTwo);
		statTblTwo << append(newParam);

statTblThree = outlineBox("Stat Three Table",
	buttonBox("Add Parameter",
		newParam = addParam(parameterList, statListThree);
		statTblThree << append(newParam);

tblList = {statTblOne, statTblTwo, statTblThree};

//Window to hold all table data and limits set by user
guiWindow = newWindow("Table Window");

//Add all stat tables into guiWindow
for(i=1, i<=nItems(tblList), i++,
	guiWindow << append(eval(tblList[i]));

Re: Button Box Created By Function References Incorrect Variable

Sorry, no time for debugging. But a tip. 

Use Print("") and Show() statements in your code to write values/parameters into the log, this often helps to narrow down the problem. From what I saw the issue is a bad/overwritten reference when pressing the add Row button.


Also you may want to use "Names Default to Here(1)" in your script as you may overwrite your variables using globals. Just some thoughts without looking much into it.

Article Labels