Subscribe Bookmark RSS Feed

How to dynamically create "n" number of Table Boxes (or other Dialog Boxes)

csoon1

Community Trekker

Joined:

Feb 9, 2016

I just started learning JSL and am stuck with an idea on my mind which I just don't know how to convert into JSL code. Basically I wanted to create a window with Table Boxes on it. The number of table boxes is not fixed and would depend on factors that are controlled by the user.

If all is well this is what I would have in mind:

For( i = 1, i <= 4, i++,

  Table Box(

  String Col Box( "Test Name", testName ),

  String Col Box( "Units", testUnits ),

  Number Col Box( "Min Limit", testMin ),

  Number Col Box( "Max Limit", testMax )

  )

)

As you can see I would have wanted to repeatedly create Table Boxes that are populated by Associative Arrays (for example: testName[1] = {"Name1", "Name2", "Name3"})

I tried putting the Table Box inside a "For Loop" and it did not seem to work. I need help with this. I tried reading limited resources online and I have not seen an example where a number of dialog boxes are dynamically generated.

I appreciate it if you can share any solution or possible work-around.

2 REPLIES
pmroz

Super User

Joined:

Jun 23, 2011

You need to put the tableboxes somewhere in order to use them.  I created an empty vlistbox and then appended each tablebox to it.

s1 = {"aaa", "bbbb", "ccc", "ddd"};

s2 = {"Hello", "World", "Fuzzball", "Wildcats"};

n1 = {1, 2, 3, 4};

n2 = {6, 7, 8, 9};

vlb = V List Box();

For( i = 1, i <= 4, i++,

    tb = Table Box(

        String Col Box( "Test Name", s1 ),

        String Col Box( "Units", s2 ),

        Number Col Box( "Min Limit", n1 ),

        Number Col Box( "Max Limit", n2 )

    );

    vlb << append(tb);

);

nw = new window("Testing", vlb);

csoon1

Community Trekker

Joined:

Feb 9, 2016

Thank you very much! It's the solution I needed.