Hi All,
I am trying to write some JSL code that takes data from a data table and graphically displays it for the user to choose from for further analysis. What I'd like to get is something like a mix between the Eigenvalue report from the PCA platform and the Effect Summary report from the Fit Model Platform. I'd like the visual to look like the PCA report, but the functionality (i.e. being able to select a row) of the Effect Summary report.
PCA Eigenvalue report (how I want it to look):

Fit Model Effect Summary report (the functionality I'd like). In this platform one can select a row in the List Box() and choose to "remove" or "add". I don't want to remove or add, but I do want the user to be able to select the row (from the above output):

I've attached the data table I'm working with, this is the "Current Data Table()" in the JSL code below. The JSL code below can get me part of the way, but not exactly what I want.
Names Default To Here( 1 );
PC_dt = Current Data Table();
PC_n = {};
PC_eigv = {};
PC_per = {};
PC_cump = {};
For( i = 1, i <= N Rows( PC_dt ), i++,
Insert Into( PC_n, PC_dt:"Number"n[i] );
Insert Into( PC_eigv, Round( PC_dt:"Eigenvalue"n[i], 5 ) );
Insert Into( PC_per, Round( PC_dt:"Percent"n[i], 5 ) );
Insert Into( PC_cump, Round( PC_dt:"cumulative Percent"n[i], 5 ) );
);
PC_Rpt_win = New Window( "PC Results",
Outline Box( "Eigenvalues & cumulative Percent",
//List Box(
//List Box(
Table Box(
Number Col Box( "Number", Eval List( PC_n ) ),
Number Col Box( "Eigenvalue", Eval List( PC_eigv ), <<SET format=""></SET>
With the commented out sections I get the following output from the code (no row is selectable, though):

I really don't know if I need the whole pre-Outline box portion of the code where I generate lists for the PCs and eigenvalues, etc. But, it seemed like the logical way to do it since I'm dealing with columns in a data table and the functions require lists. It works, even if not necessary.
</CODE></P><P> </P><P> If I include either or both of the commented-out List Box() calls around the Table Box(), I get the following. Rows are selectable, but nothing shows up:</P><P><SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DiedrichSchmidt_3-1635336043749.png" style="width: 400px;"><IMG src="https://us.v-cdn.net/6038925/uploads/images/37045iA319787974999980/DiedrichSchmidt_3-1635336043749.png" role="button" title="DiedrichSchmidt_3-1635336043749.png" alt="DiedrichSchmidt_3-1635336043749.png" /></SPAN></P><P> I'm not sure what I'm doing wrong, and the Scripting Index has limited examples of how to correctly use the List Box() call with a Table Box(). I tried following the tree structure from the Fit Model platform report window, but it's not working.</P><P> </P><P>In summary, I'd like to correct the following in my script:</P><OL><LI>Correct the Plot Col Box so that it has the cumulative percent curve like the PC report shows (first image above). This is not as critical as item 2.</LI><LI>Correct the List Box() call around the Table Box() so that the user can select a row in the List Box that will then get sent on to another function for further analysis.</LI></OL><P>Thanks for any suggestions and help!,</P><P>DS</P></LINGO-BODY><LINGO-LABS id="lingo-labs-430708" slang="en-US"><LINGO-LABEL>Scripting</LINGO-LABEL></LINGO-LABS><LINGO-SUB id="lingo-sub-430729" slang="en-US">Re: Scripting help for Table Box() within a List Box()</LINGO-SUB><LINGO-BODY id="lingo-body-430729" slang="en-US"><P>Is there a specific need for List Box()? You can use <CODE class=""><< Set Selectable Rows(); to make rows selectable in Table Box and then use << set row change function(Function({this}, ); to add function to selection.
Example from Scripting Index:
Names Default To Here(1);
New Window("Mountains",
tb = Table Box(
String Col Box("Mountain", {"K2", "Delphi", "Kilimanjaro", "Grand Teton"}),
Number Col Box("Elevation (meters)", {8611, 681, 5895, 4199}),
Plot Col Box("", {8611, 681, 5895, 4199})
)
);
tb << Set Selectable Rows();
tb << set row change function(Function({this}, Print(this << get selected rows)));
Hi @jthi ,
Thanks for your quick feedback. I had tried that earlier, but nothing had happened, so I abandoned it for another route, but it wasn't leading anywhere. I went back and tried it, and it works, thank you! The added functionality is helpful. That definitely solved item 2, which was the more important one. If there's any idea how to fix item 1, that would be great, but not essential.
This is related, but maybe another thread (let me know and I'll repost it as another thread).
Do you know how to use JSL to save the DModX and T² values from the PCA platform to the data table? All this is to try and automate this process, or at least take out several of the other steps and just give the user the basics for deciding on the number of PCs to then use for saving the DModX and T² formulas.
Thanks!,
DS
Hi @jthi ,
Well, forget the part about DModX, the Scripting Index showed me how to do that and it works as expected. It has an example for Save T Square, but that's not working. I'll keep at it. I think I need to reference the right Outline box.
Thanks!,
DS
For item 1:
I would guess there is some other / better way to do this, but I found << Lower and << Upper (requires Lower to be specified) messages. With << Lower you could get first values from the Cumulative Column and then set those to Plot Col Box with Lower
pcb << Lower(ncb << get as matrix);

With your code it would look something like this (add references and use those):
View more...Names Default To Here( 1 );
PC_dt = Current Data Table();
PC_n = {};
PC_eigv = {};
PC_per = {};
PC_cump = {};
For( i = 1, i <= N Rows( PC_dt ), i++,
Insert Into( PC_n, PC_dt:"Number"n[i] );
Insert Into( PC_eigv, Round( PC_dt:"Eigenvalue"n[i], 5 ) );
Insert Into( PC_per, Round( PC_dt:"Percent"n[i], 5 ) );
Insert Into( PC_cump, Round( PC_dt:"cumulative Percent"n[i], 5 ) );
);
PC_Rpt_win = New Window( "PC Results",
Outline Box( "Eigenvalues & cumulative Percent",
//List Box(
//List Box(
Table Box(
Number Col Box( "Number", Eval List( PC_n ) ),
Number Col Box( "Eigenvalue", Eval List( PC_eigv ), <<SET format=""></SET>For getting values:
Sometimes it might be enough to use Make into data table (depending on platform and if you are using By variable):

and then checking from the resulting table the table script:


Sometimes that gives quite quick way to get references to correct Display Boxes.
Hi @jthi ,
Thanks again for your quick feedback and help. Yes, the <
Now, my only problem is how to save T². Each time I try to address the outline box in question from the PCA platform, I get a log error that says the display box doesn't recognize <
Thanks!,
DS