cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
matt7109
Level III

Display selected file in button box

Hi there,

I have a button that prompts user to select 2 files. However, once the user clicks the button and picks a file, I would like the path name to show up on the button so that the user knows the file was correctly selected. In the photo below, once a user picks a file, I want that selected path to show up in the highlighted area. 

Button.PNG

Current Code:

New Window( "Data and Limits file",
	<<modal,
	Text box(""),
	Text box("Choose a data file:"),
	Button Box( "Pick file", D = Pick File()),
	//Text box(L),
	Text box (""),
	Text box (""),
	Text box("Choose a limits file:"),
	Button Box( "Pick File", L = Pick File()),
	//Text box(D),
	Text box(""),
	Text box (""),
	);

Thanks!

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Display selected file in button box

Here is the script.  The documentation on all of the features that can be used with a given function or display object is available at:

     Help==>Scripting Index

It will give you all of the details, and examples 

Names Default To Here( 1 );
New Window( "Data and Limits file",
	<<modal,
	Spacer Box( size( 10, 10 ) ),
	Text Box( "Choose a data file:" ),
	BB1 = Button Box( "Pick file",
		D = Pick File();
		If( D != "",
			BB1 << set button name( D )
		);
	), 
	//Text box(L),
	Spacer Box( size( 20, 10 ) ),
	Text Box( "Choose a limits file:" ),
	BB2 = Button Box( "Pick File",
		L = Pick File();
		If( L != "",
			BB2 << set button name( L )
		);
	), 
	//Text box(D),
	Spacer Box( size( 20, 10 ) ) 

);
Jim

View solution in original post

Jeff_Perkinson
Community Manager Community Manager

Re: Display selected file in button box

@txnelson's solution changes the text of the button, which is what the title of your post says you wanted.

 

But, the picture you provided looks like you want the name of the file below the button – not in the button.

 

If that's what you really want here's a modification of Jim's code that will get you there.

 

Names Default To Here( 1 );
New Window( "Data and Limits file",
	<<modal,
	Spacer Box( size( 10, 10 ) ),
	Text Box( "Choose a data file:" ),
	BB1 = Button Box( "Pick file",
		D = Pick File();
		If( D != "",
			file1 << set text( D )
		);
	),
	file1 = Text Box( ), 
	//Text box(L),
	Spacer Box( size( 20, 10 ) );,
	Text Box( "Choose a limits file:" ),
	BB2 = Button Box( "Pick File",
		L = Pick File();
		If( L != "",
			file2 << set text( L )
		);
	),
	file2 = Text Box(  ), 
	//Text box(D),
	Spacer Box( size( 20, 10 ) ) 

	;
);
-Jeff

View solution in original post

6 REPLIES 6
txnelson
Super User

Re: Display selected file in button box

Here is the script.  The documentation on all of the features that can be used with a given function or display object is available at:

     Help==>Scripting Index

It will give you all of the details, and examples 

Names Default To Here( 1 );
New Window( "Data and Limits file",
	<<modal,
	Spacer Box( size( 10, 10 ) ),
	Text Box( "Choose a data file:" ),
	BB1 = Button Box( "Pick file",
		D = Pick File();
		If( D != "",
			BB1 << set button name( D )
		);
	), 
	//Text box(L),
	Spacer Box( size( 20, 10 ) ),
	Text Box( "Choose a limits file:" ),
	BB2 = Button Box( "Pick File",
		L = Pick File();
		If( L != "",
			BB2 << set button name( L )
		);
	), 
	//Text box(D),
	Spacer Box( size( 20, 10 ) ) 

);
Jim
matt7109
Level III

Re: Display selected file in button box

Perfect!!! Thanks so much!

Jeff_Perkinson
Community Manager Community Manager

Re: Display selected file in button box

@txnelson's solution changes the text of the button, which is what the title of your post says you wanted.

 

But, the picture you provided looks like you want the name of the file below the button – not in the button.

 

If that's what you really want here's a modification of Jim's code that will get you there.

 

Names Default To Here( 1 );
New Window( "Data and Limits file",
	<<modal,
	Spacer Box( size( 10, 10 ) ),
	Text Box( "Choose a data file:" ),
	BB1 = Button Box( "Pick file",
		D = Pick File();
		If( D != "",
			file1 << set text( D )
		);
	),
	file1 = Text Box( ), 
	//Text box(L),
	Spacer Box( size( 20, 10 ) );,
	Text Box( "Choose a limits file:" ),
	BB2 = Button Box( "Pick File",
		L = Pick File();
		If( L != "",
			file2 << set text( L )
		);
	),
	file2 = Text Box(  ), 
	//Text box(D),
	Spacer Box( size( 20, 10 ) ) 

	;
);
-Jeff
adam
Level IV

Re: Display selected file in button box

Hi,

Just an idea I thought of. From the script, understood that it allows us to open 2 files based on the path selected. Once the each file is open, how can we assign it as data table to automatically create for example a distribution(or a simple Fix Y-X) plot. Thanks.

txnelson
Super User

Re: Display selected file in button box

Here are 2 simple scripts that illustrate how to create a handle to the different data tables, and then to use that handle to determine which analysis to use with what data table.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\iris.jmp" );
dt2 = Open( "$SAMPLE_DATA\big class.jmp" );

dt << Distribution(
	Continuous Distribution( Column( :Sepal length ) ),
	Continuous Distribution( Column( :Sepal width ) ),
	Continuous Distribution( Column( :Petal length ) ),
	Continuous Distribution( Column( :Petal width ) )
);

dt2 << Oneway( Y( :height ), X( :age ), Means( 1 ), Mean Diamonds( 1 ) );
Names Default To Here( 1 );
dtList = {};
dt = Open( "$SAMPLE_DATA\iris.jmp" );
Insert Into( dtlist, dt );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
Insert Into( dtlist, dt );

dtList[1] << Distribution(
	Continuous Distribution( Column( :Sepal length ) ),
	Continuous Distribution( Column( :Sepal width ) ),
	Continuous Distribution( Column( :Petal length ) ),
	Continuous Distribution( Column( :Petal width ) )
);

dtList[2] << Oneway( Y( :height ), X( :age ), Means( 1 ), Mean Diamonds( 1 ) );
Jim
adam
Level IV

Re: Display selected file in button box

Thanks a lot, Jim !