Am I going crazy or How is that possible? - Need help troubleshooting weird behaviourIssue in my App that I was troubleshooting the whole day. I narrowed it down to this very qeird behaviour. Unless I'm missing something, this should not be this way.
I have two tables opened: "Baseball" and "Basketball".
I have this script:
Clear Log();
//dt_current=Data Table("Basketball");
/*Two tables opened: Baseball and Basketball. The table named "Basketball" is selected as current table*/
dt_working=Data Table("Baseball");
Show("This is the dt_working table:");
Show(dt_working<<GET name=""></GET>Obviously, I'm trying to create a Col List Box with columns from Baseball Table.
But this is what my log (and the rest of the App) showing me:
"This is the dt_working table:";
dt_working << Get Name() = "Baseball";
"Columns names:";
colNamesList = {Player, Batting};
"This is what dt_working still is:";
dt_working << Get Name() = "Baseball";
"But this is what I got in Col List Box:";
colListX << Get Items = {"School", "CSN", "Durham Sun", "Durham Herald", "Washington Post", "USA Today", "Sports Magazine", "In Sport", "UPI", "AP", "Sports Illustrated"};For some reason even though I specified dt_working to be Baseball and said that Col List Box is created using table dt_working, it populates Col List Box with columns from the current data table that I chose in the tool bar up top.
Another app that generally has different code but that particular part is exactly the same works differently and how I intended it to work. Can somebody help me troubleshoot it further? Why owuld it populate Col List Box not form the table I told it to populate, but from the current table?
In the long run I'm trying to display columns from tables that I select in a different List Box. A similar functionality in another app works just fine. Here no matter what table I click (and run a code similar to one I cited) it always shows columns from the table selected up top.
Thanks,
M.
Re: Am I going crazy or How is that possible? - Need help troubleshooting weird behaviour@MathStatChem wrote:
lso, looking at the syntax in the scripting guide, it appears that the syntax doesn't allow for the use of a data table reference, you have to use the syntax:
y=Col List Box(,...)
The Data Table() in the arguments for the Col List Box() isn't a function it's a named argument to let Col List Box() know that the argument should be interpreted as a data table. As such it does take a data table reference as an argument. Here's an example:
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA\Solubility.jmp" );
New Window("Example", Col List Box( Data Table( dt ), all ) );
There's no need for the <
We'll look at trying to automatically detect whether the first argument is a data table reference.
Thanks to @Justin_Chilton for the explanation.
Re: Am I going crazy or How is that possible? - Need help troubleshooting weird behaviour
@gzmorgan0wrote:
Yes, that was my recommendation to use ColListBox( Data Table( dt_ref << getname ), ...)
And it works! You saved me twice today!
Re: Am I going crazy or How is that possible? - Need help troubleshooting weird behaviourOkay, maybe not a bug, I'll have to look up old emails, but I found a reference with ColListBox(dt,...) somewhere and flagged JMP.
Yes, that was my recommendation to use ColListBox( Data Table( dt_ref << getname ), ...)
Re: Am I going crazy or How is that possible? - Need help troubleshooting weird behaviourAlso, looking at the syntax in the scripting guide, it appears that the syntax doesn't allow for the use of a data table reference, you have to use the syntax:
y=Col List Box(,...)
so using this code
y=Col List Box( Data Table(dt_working<<GET name=""></GET>
gives you the desired result. I don't think it is a bug, it is just clunky syntax.
Re: Am I going crazy or How is that possible? - Need help troubleshooting weird behaviourAh, ok, I see. So the Col List Box is using the current data table, not the data table reference. A quick fix, is to insert into the script, just before the colList statement, this statement:
Current Data Table(dt_working);
Re: Am I going crazy or How is that possible? - Need help troubleshooting weird behaviourYes, I had that another script opened, but there it was working as
intended. I will try Georgia's workaround and let you guys know if it works. I had a
strong suspicion it was a big, it was not clear for me what was triggering
it since exactly the same code worked fine in another app.Re: Am I going crazy or How is that possible? - Need help troubleshooting weird behaviourI ran your code, using the Baseball.JMP table from the example data, and I did not see the behaviour that you are seeing. Here is my log output.
"This is the dt_working table:";
dt_working << Get Name() = "Baseball";
"Columns names:";
colNamesList = {Player, Batting};
"This is what dt_working still is:";
dt_working << Get Name() = "Baseball";
"But this is what I got in Col List Box:";
colListX << Get Items = {"Player", "Batting"};Did you have another script open where you had created the colListX reference, perhaps with another table?
It may be best to use the Names Default to Here(1) command at the beginning of the script. If you don't do that, then all your variables are global, and two different scripts can walk over each other's variables.
Re: Am I going crazy or How is that possible? - Need help troubleshooting weird behaviourI would call this a bug. I got caught by this last year. However, there is a solution. The problem is that ColListBox is not evaluating or parsing the table reference dt_working. My recommendation is to use the syntax ColListBox( Data Table(dt_working << get name), .... or to make the intended table the current data table, when colListX is created.
hmmm my JSl is wrapping. Script attached.
open("$Sample_data/Basketball.jmp");<BR />open("$Sample_data/Baseball.jmp");<BR /><BR />Clear Log();<BR /> //dt_current=Data Table("Basketball");<BR /> /*Two tables opened: Baseball and Basketball. The table named "Basketball" is selected as current table*/<BR /> dt_working=Data Table("Baseball");<BR /> <BR /> Show("This is the dt_working table:");<BR /> Show(dt_working<<GET name=""></GET> colNamesList = dt_working << Get Column Names;<BR /> show("Columns names:");<BR /> show(colNamesList);<BR /> show(current data table()); //Baseball<BR /> <BR /> colListX = Col List Box (all, width(250), maxSelected(1));<BR /> show(colListX<<GET items=""></GET><BR /> //_______________________________________________________<BR /> <BR /> Write("\!N" ||Repeat("_",60)||"\!N");<BR /> <BR /> //make Basektball current <BR /> <BR /> current data table(Data Table("Basketball"));<BR /> <BR /> colListX = Col List Box (dt_working, all, width(250), maxSelected(1));<BR /> show(colListX<<GET items=""></GET><BR /> colListX = Col List Box (NameExpr(dt_working), all, width(250), maxSelected(1));<BR /> show(colListX<<GET items=""></GET><BR /> colListX = Col List Box (Data Table("Baseball"), all, width(250), maxSelected(1));<BR /> show(colListX<<GET items=""></GET> <BR /> <BR /> colListX = Col List Box (Data Table(dt_working<<GET name=""></GET> show(colListX<<GET items=""></GET><BR /><BR /> Eval( <BR /> Parse( EvalInsert("colListX = ColListBox( ^dt_working^, all, width(250), maxSelected(1));") )<BR /> );<BR /> wait(0);<BR /> show(colListX<<GET items=""></GET>