Assign data table to ColumnDialog<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I wish to have a script that allow me to select columns from the chosen data table (which are still open). I started the script by choosing from list of opened data table. Somehow, this chosen data table does not assign to ColumnDialog
How to set the current data table based by selecting from open data table list and have it assigned to ColumnDialog?
My script is as followed:
Data
OpenDT = List();
For( i = 1, i <= N Table(), i++, Insert Into( OpenDT, Data Table(i) ));
dlgDT = Dialog( "Please select 1 Data Table for analysis",
VList(selectDT = List Box( OpenDT)) ,
HList (Button ("OK", dt_name = selectDT << Get Name, set << current data table (dt_name)),
Button ("Cancel", Stop())
));
colDT = ColumnDialog ( Title ("Test"),
L1uSelect = ColList ("L1 u_prime : ", Max Col (1), Min Col (1), DataType ( Numeric )),
L1vSelect = ColList ("L1 v_prime : ", Max Col (1), Min Col (1), DataType ( Numeric )),
L2uSelect = ColList ("L2 u_prime : ", Max Col (1), Min Col (1), DataType ( Numeric )),
L2vSelect = ColList ("L2 v_prime : ", Max Col (1), Min Col (1), DataType ( Numeric ))
);
L1u = colDT["L1uSelect"];
L1v = colDT["L1vSelect"];
L2u = colDT["L2uSelect"];
L2v = colDT["L2vSelect"];
Re: Assign data table to ColumnDialogThanks a lot. It's very helpful!
Re: Assign data table to ColumnDialogThe Dialog() function returns a list of the items constructed within the dialog. You don't put expressions in the Button() elements of a Dialog(). Instead, you unpack the list after the dialog is dismissed.
Here's a working form of your example:
OpenDT = List();
For( i = 1, i <= N Table(), i++,
Insert Into( OpenDT, Data Table( i ) )
);
dlgDT = Dialog(
"Please select 1 Data Table for analysis",
VList( selectDT = List Box( OpenDT ) ),
HList( Button( "OK" ), Button( "Cancel" ) )
);
Show( dlgDT );
If( dlgDT["button"] == 1,
Remove From( dlgDT, N Items( dlgDT ) );
Eval List( dlgDT );
);
Current Data Table( selectDT[1] );
colDT = Column Dialog(
Title( "Test" ),
L1uSelect = ColList( "L1 u_prime : ", Max Col( 1 ), Min Col( 1 ), DataType( Numeric ) ),
L1vSelect = ColList( "L1 v_prime : ", Max Col( 1 ), Min Col( 1 ), DataType( Numeric ) ),
L2uSelect = ColList( "L2 u_prime : ", Max Col( 1 ), Min Col( 1 ), DataType( Numeric ) ),
L2vSelect = ColList( "L2 v_prime : ", Max Col( 1 ), Min Col( 1 ), DataType( Numeric ) )
);
L1u = colDT["L1uSelect"];
L1v = colDT["L1vSelect"];
L2u = colDT["L2uSelect"];
L2v = colDT["L2vSelect"];
Frankly speaking, Dialog() is less convenient that the New Window() construct for building displays. It requires special constructors for display elements and the list that it returns is clumsy to work with. That's one reason it's been deprecated. See the online documentation for creating modal displays to see how to use New Window() instead.
-Jeff