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

Column Dialog box to select and save column name for selected column

Hi All,

 

I want to create a dialog box which show all the column names available to the data. It will allow to select the required column and save column name to the variable. So, that I access that column in jsl using the name stored in the variable.

For Example: I have following table.

ABC
johnMath78
AdamScience90
ChrisScience67

 

If I run the script it will open the dialog (as shown in image) and after selection of column I want to access them using the variable name in which that ccolumn is stored. ( for eg. column(dt,score) ) 

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Staff

Re: Column Dialog box to select and save column name for selected column

Take a look at this slightly changed code:

NamesDefaultToHere(1);

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

// Modal dialog: Note that 'ColumnDialog()' is a variant of the deprecated 'Dialog()', so you 
// should probably look at 'NewWindow()' with the  '<< Modal' option
dlg = Column Dialog(																	
			name = ColList( "Name", Min Col(1), Max Col(1) ), 								
			subject = ColList( "Subject", Min Col(1), MaxCol(1) )
			);

// Stop if the user did not press 'OK'		
If( dlg["Button"] != 1, Beep(); Throw());

// Note that 'name' and 'subject' will both be lists - Look at the tooltip when you point to the variable																	
name = dlg[ "name" ];
subject = dlg["subject"];

// If you require column names . . .
name = Column(dt, name[1]) << getName;
subject = Column(dt, subject[1]) << getName;
Print(name, subject);

View solution in original post

3 REPLIES 3
ian_jmp
Staff

Re: Column Dialog box to select and save column name for selected column

To get started, use 'Help > Scripting Index' and search for 'Col List Box'. There are three examples.

Rajat
Level IV

Re: Column Dialog box to select and save column name for selected column

Hi @ian_jmp 

 

I wrote the following code.

 

dlg = Column Dialog(																	
			name = ColList( "Name", Min Col(1), Max Col( 1 ) ), 								
			subject = ColList( "Subject", Min Col(1) ),
				
			);
		
		If( dlg["Button"] == 1, 																
	
			name = dlg[ "name" ];
			subject = dlg["subject"]
						
			);

So, After run, when I print the name, it prints ":A". It refers to the whole column but I want to get only the column name. How I can resolve the issue. Also sometime if I am working with multiple data tables it shows error can't access column 'A' because the row number (0) is not valid. 

Please help how I can resolve this issue.

 

Thanks

ian_jmp
Staff

Re: Column Dialog box to select and save column name for selected column

Take a look at this slightly changed code:

NamesDefaultToHere(1);

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

// Modal dialog: Note that 'ColumnDialog()' is a variant of the deprecated 'Dialog()', so you 
// should probably look at 'NewWindow()' with the  '<< Modal' option
dlg = Column Dialog(																	
			name = ColList( "Name", Min Col(1), Max Col(1) ), 								
			subject = ColList( "Subject", Min Col(1), MaxCol(1) )
			);

// Stop if the user did not press 'OK'		
If( dlg["Button"] != 1, Beep(); Throw());

// Note that 'name' and 'subject' will both be lists - Look at the tooltip when you point to the variable																	
name = dlg[ "name" ];
subject = dlg["subject"];

// If you require column names . . .
name = Column(dt, name[1]) << getName;
subject = Column(dt, subject[1]) << getName;
Print(name, subject);