cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
View Original Published Thread

User Interface- How to use a Checkbox to run a function

Raybob
Level II

I am attempting to build a UI that asks for the user to select "Products" from a list, and then create a graph of each product and adding "Material" to then graph title based on if the check box is selected or not.

 

So far I have my UI window, but I am lost on how to connect it to my graph script. I think something like an If statement may be the key, but I may be wrong.

 

Names Default To Here( 1 );
dt = Data Table( "untitled 16" );
values = dt:Product << Get Values;
array = Associative Array( values );
ProductList = array << Get Keys;
Final Products = {};
// Prompt for the input and create graph
FP = New Window( "Choose the Final Products",
	<<Modal,
	<<return result,
	H List Box( Spacer Box( Size( 10, 30 ) ) ),
	V List Box(
		align( center ),
		Spacer Box( Size( 10, 10 ) ),
		Panel Box( "Select the Final Products", Spacer Box( Size( 10, 10 ) ), checkObj = Check Box( ProductList ), )
	), 

	//If Check box is checked (FP), then add "Material -GPC Overlay" to the title. Otherwise, Add "-GPC Overlay" to the title.
	Button Box( "OK", 
       //script that executes upon clicking "OK"
		keep_going = 1;

		Final_Products = checkObj << get selected;

	), 

           

);

nt = N Items( Final_Products );

If( keep_going & nt > 0, 

	For( i = 1, i <= nt, i++, 

		If(
			Final_Products[i] == 1, 

//              Call function for One step

				Print( {1} ); // I tried "1" , but I'm missing something here. I am guessing I can insert the graph function here rather than print, but I was using print to check my work.

		, 

			Final_Products[i] == 2, 

//              Call function for Two step

				Print( 2 ); // I tried "2" , but I'm missing something here

 

		);

	);

);
FP << Close Window;
1 REPLY 1
jthi
Super User


Re: User Interface- How to use a Checkbox to run a function

Add two help prints:

  1. Print Final products before first If. I would suggest "printing" it with Show(Final Products)
  2. Add second print inside your for loop for Final_Products[i]  before first if inside the loop

These might give you a good idea what could be wrong

-Jarmo