cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
swiergi11
Level III

How to use variable selected in combo box into data extraction path

Hi,

I'm quite new to JMP, got script with combo box and intending to use that selected character to be insert into the  path for  data extraction , any suggestion welcome .

 

Thanks

 

Names Default To Here( 1 );
Clear Symbols();
Clear Globals();

New Window( "Combo box test", 
	<< Modal,
	Panel Box( "Select a Date Range",
		Lineup Box( N Col( 1 ), 

			Text Box( "DCOP ID" ), 
			
			dc_cb = Combo Box(
				{"CED15_10", "CDM45.10", "CRL02.05", "CEM11.05", "CEM09.18", "CBI07.01"},
				dc_cb << GetSelected(),
				<< Set Width( 20 )
			), 
		,
		), 
		H List Box(
			Button Box( "OK",
				<<Set Function(
					Function( {self}, 

						dcop_id = dc_cb << Get;

					)
				)
			),
			Button Box( "Cancel" )
		), 

	),

);

dt_control = Open( "\\S:data\ENG_" || dcop_id || ".CSV" );
2 ACCEPTED SOLUTIONS

Accepted Solutions
swiergi11
Level III

Re: How to use variable selected in combo box into data extraction path

Sweet, works nice.

 

Any chance I could use combo box and get  outcome as a number?

Names Default To Here( 1 );

New Window( "Combo box test", 
	<< Modal,
	Panel Box( "Select a Date Range",
		Lineup Box( N Col( 1 ), 
			Text Box( "DCOP ID" ), 
			dc_cb = Combo Box(
				{"10", "20", "30"},
				dc_cb << GetSelected(),
				<< Set Width( 20 )
			)
		), 
		H List Box(
			Button Box( "OK",
				<<Set Function(
					Function( {self}, 

						//Insted "10" as text will need 10 as number???
						dcop_id = dc_cb << Get ;
					)
				)
			),
			Button Box( "Cancel" )
		), 
	),
);
//dcop_id is an number
Write( "\\S:data\ENG_" || dcop_id || ".CSV" );

 

 

View solution in original post

txnelson
Super User

Re: How to use variable selected in combo box into data extraction path

All you need to do is to use the Num() function to convert the character string to numeric.  Also, you need to use the Get Selected message, not the Get message.  Get Selected returns the value, while Get returns the index number.

See the Scripting Index for definition of the messages available to the Combo Box().

dcop_id = Num( dc_cb << Get Selected ) ;

I strongly suggest that you take the time to read the Scripting Guide found in the JMP Documentation Library, under the Help Menu.  It will really provide you with the background that will make your venture into JSL a far easier task.

Jim

View solution in original post

4 REPLIES 4
ih
Super User (Alumni) ih
Super User (Alumni)

Re: How to use variable selected in combo box into data extraction path

The message Get returns an integer from the combobox, I think you instead want Get Text.  See this updated script:

 

Names Default To Here( 1 );

New Window( "Combo box test", 
	<< Modal,
	Panel Box( "Select a Date Range",
		Lineup Box( N Col( 1 ), 
			Text Box( "DCOP ID" ), 
			dc_cb = Combo Box(
				{"CED15_10", "CDM45.10", "CRL02.05", "CEM11.05", "CEM09.18", "CBI07.01"},
				dc_cb << GetSelected(),
				<< Set Width( 20 )
			)
		), 
		H List Box(
			Button Box( "OK",
				<<Set Function(
					Function( {self}, 

						//Updated this to Get Text
						dcop_id = dc_cb << Get Text;
					)
				)
			),
			Button Box( "Cancel" )
		), 
	),
);

Write( "\\S:data\ENG_" || dcop_id || ".CSV" );

Check out the scripting index to see more detail on those messages.

ih_0-1613759943323.png

 

swiergi11
Level III

Re: How to use variable selected in combo box into data extraction path

Sweet, works nice.

 

Any chance I could use combo box and get  outcome as a number?

Names Default To Here( 1 );

New Window( "Combo box test", 
	<< Modal,
	Panel Box( "Select a Date Range",
		Lineup Box( N Col( 1 ), 
			Text Box( "DCOP ID" ), 
			dc_cb = Combo Box(
				{"10", "20", "30"},
				dc_cb << GetSelected(),
				<< Set Width( 20 )
			)
		), 
		H List Box(
			Button Box( "OK",
				<<Set Function(
					Function( {self}, 

						//Insted "10" as text will need 10 as number???
						dcop_id = dc_cb << Get ;
					)
				)
			),
			Button Box( "Cancel" )
		), 
	),
);
//dcop_id is an number
Write( "\\S:data\ENG_" || dcop_id || ".CSV" );

 

 

txnelson
Super User

Re: How to use variable selected in combo box into data extraction path

All you need to do is to use the Num() function to convert the character string to numeric.  Also, you need to use the Get Selected message, not the Get message.  Get Selected returns the value, while Get returns the index number.

See the Scripting Index for definition of the messages available to the Combo Box().

dcop_id = Num( dc_cb << Get Selected ) ;

I strongly suggest that you take the time to read the Scripting Guide found in the JMP Documentation Library, under the Help Menu.  It will really provide you with the background that will make your venture into JSL a far easier task.

Jim
swiergi11
Level III

Re: How to use variable selected in combo box into data extraction path

Thanks a lot, that works perfectly, will do.

Thanks again