Hi, I am new using JMP and JSL and I am having trouble creating a script that selects a table, then 2 columns and then do something with that.
Here is an example
Names Default to Here( 1 );
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, DataTable(t) << getName);
);
// Select the table
nw = New Window("Test", <<Modal,
PanelBox("Pick a table",
dtlb = ListBox(dtNames, MaxItems(1))
),
ButtonBox("OK", OKscript)
);
OKScript = Expr(
nw << closeWindow;
dtName = dtlb << getSelected;
dt = Data Table(dtName[1]);
if(NItems(dtName) > 0,
Print("Table selected: "||dtName[1]),
Print("No table selected")
)
);
/* Here I tried several options like
current data table (dt);
dt << get data table;
and other but I cannot find what fits well */
xvar = .;
yvar = .;
win = New Window( "Compared Values",
<<Modal,
// require the user to select two variables before clicking OK
<<On Validate(
Show( xvar, yvar );
If( Is Missing( xvar ) | Is Missing( yvar ),
0, // if xvar or yvar are missing, do nothing when OK is clicked
1
);
),
Text Box( " Select test values. " ),
H List Box(
Text Box( "Select Variable " ),
x = Col List Box(
dt, // data table reference
all, // display all columns from the data table
xvar = (x << Get Selected)[1];
// get the name of the selected column before the window closes
Show( xvar );
),
Text Box( "Select ID" ),
y = Col List Box(
dt,
all,
yvar = (y << Get Selected)[1];
Show( yvar );
)
)
);
xcol = Column( dt, xvar ); // get the columns
ycol = Column( dt, yvar );
Graph Builder(
Show Control Panel( 0 ),
Show Legend( 0 ),
Show Title( 1 ),
Variables( X( ycol ), Y( xcol ) ),
Elements( Points( X, Y, Legend( 6 ) ) )
);
In this example I am trying a simple script where I can select one of the already open tables, select 2 columns, and do a simple plot. However I cannot manage to make the program to recognise the specific table that I select.
In the future I will need to interact with few tables at the same time and select different columns from different tables to obtain my results. I thought that this script would be an easy start. I would be very thankful if somebody could also provide me with a short explanation on why I cannot select the table that I'm choosing in the first box, or how to improve it, together with the solution to my script.
Thanks!