Choose Language Hide Translation Bar
Highlighted
Feli
Level II

Connecting table variable to slider box

I have a table variable A that is connected to some formulas in my data table.

dt = currentdatatable();
dt << Set Table Variable( "A", 1 );

I want to build an application using the Application Builder where I move a slider using the Slider Box and this updates my table variable A in the data table, i.e. if the slider is changed to 2, A is updated to 2 in the data table.

How could I connect those two? I know I can update a table variable using JSL:

dt << Set Table Variable( "A"), 2 );

Is there a way of combining the running of a short script that updates the table variable when dragging the slider? I tried putting in the script in the Move-> Edit scripts under the Properties Window of the slider box

dt = Current Data Table();
dt << Set Table Variable("A"), mySlider );

with Variable Name mySlider, but when running the Application, I get the error image.png

when moving the slider, so I must be doing something wrong.

Any hints?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Connecting table variable to slider box

You have to use the Slider Box object in a window. The box has a script that is evaluated whenever the slider is changed. Use this script to change the table variable. Also, you can use the << Set Table Variable message, or because table variables behave like columns in an expression (formula, script), you can simply and directly assign the new value.

 

This example should show you how to use a Slider box script.

 

Names Default to Here( 1 );

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

dt << New Table Variable( "Parameter", 1 );

New Window( "Sliding",
	Outline Box( "Control",
		Slider Box( 1, 10, p,
			dt:Parameter = p;
		)
	)
);
Learn it once, use it forever!

View solution in original post

2 REPLIES 2
Highlighted

Re: Connecting table variable to slider box

You have to use the Slider Box object in a window. The box has a script that is evaluated whenever the slider is changed. Use this script to change the table variable. Also, you can use the << Set Table Variable message, or because table variables behave like columns in an expression (formula, script), you can simply and directly assign the new value.

 

This example should show you how to use a Slider box script.

 

Names Default to Here( 1 );

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

dt << New Table Variable( "Parameter", 1 );

New Window( "Sliding",
	Outline Box( "Control",
		Slider Box( 1, 10, p,
			dt:Parameter = p;
		)
	)
);
Learn it once, use it forever!

View solution in original post

Highlighted
Feli
Level II

Re: Connecting table variable to slider box

That helped indeed! Thank you.
Article Labels