Choose Language Hide Translation Bar
Highlighted
Occasional Contributor

## Trouble adding a list to a Table Box

I am a newbie at JSL and I know I am missing something simple...

My code is:

``````For(i = 1, i<= NItems(x), i++,
rowNum = totByBox << Get Rows Where( :BOXID == x[i]);
xlist[i] = totByBox:FreeSpace[rowNum];

);
show(xlist[1]);

New Window ("Plasmids Location",
Table Box(
Number Col Box("Box ID", nDTbyVec[0, 1] ),
String Col Box("Vector# ", nDTbyVec[0, 2]),
Number Col Box("# of Vial", nDTbyVec[0, 4]),
Number Col Box("Space Available ", xlist),
));``````

Where I have xlist collect numbers from a data table. When I show xlist in the console, it is:

xlist = {[34], [93]};

I think I will have to convert it to {34, 93} if I hope to add it to the Number Col Box. Is there anyway to accomplish this..?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: Trouble adding a list to a Table Box

What you have done, is to place a matrix value into each of the 2 elements of your list.  You can clear that, by setting each of the List values, to the 1st element of each of your matricies.  In your case, each matrix only has one element, therefore, the following code will reset the elements in the list to simple scaler values:

``````xlist = {[34], [93]};

xlist[1]=xlist[1][1];
xlist[2]=xlist[2][1];

show(xlist);``````

The results of the Show() is:

``xlist = {34, 93};``
Jim
3 REPLIES 3
Super User

## Re: Trouble adding a list to a Table Box

What you have done, is to place a matrix value into each of the 2 elements of your list.  You can clear that, by setting each of the List values, to the 1st element of each of your matricies.  In your case, each matrix only has one element, therefore, the following code will reset the elements in the list to simple scaler values:

``````xlist = {[34], [93]};

xlist[1]=xlist[1][1];
xlist[2]=xlist[2][1];

show(xlist);``````

The results of the Show() is:

``xlist = {34, 93};``
Jim
Highlighted
Occasional Contributor

## Re: Trouble adding a list to a Table Box

Thank you for your help. That definitely worked.

Do you know if there is a funciton that can quickly convert something like this to a list? Another way I was able to take your suggestion and make it more flexible is to use a for loop where:

``````for( i = i, i<= NItems(xlist), i++,
xlist[i] = xlist[i][1];
);``````

I was just wondering if there is a built in function or another more efficient way I can do this,

Thank you again

Highlighted
Super User

## Re: Trouble adding a list to a Table Box

I do not know of a better way than using a For() Loop.  However, I suggest that you look at the place in your code, where you are creating the elements in the list, and see if as you insert an element into the list, that you convert the matrix to a scaler at that point.

Jim