Choose Language Hide Translation Bar
ram_asra_gmail_
Community Trekker

List box ignores the duplicate items from list !!

Hi all, below is simple code where i print two list using listbox. in list "Perf_cal", item 2 & 3 are same. so when i run below jsl  only item 2 or 3 is printed along with other. What i need is to print all items (8 in this case) in the list without removing any duplicates.

Thanks

 

newwindow("new",
Perf_cal = {"101.6", "100.8", "100.8", "100.2", "101", "101.8", "100", "99.2"};
Perf_item = {"a", "b", "c", "d", "e", "f", "g", "h"};
perf=hlistbox(listbox(Perf_item,width(20),nlines(8)), listbox(Perf_cal,width(50),nlines(8)));
);
0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
ih
ih
Community Trekker

Re: List box ignores the duplicate items from list !!

I am not sure about the specific list box question but I wonder if a table box would accomplish your goal.

Perf_cal = {"101.6", "100.8", "100.8", "100.2", "101", "101.8", "100", "99.2"};
Perf_item = {"a", "b", "c", "d", "e", "f", "g", "h"};
New window("new",
	tb = Table box(
		String Col Box( "Item", Perf_item ),
		String Col Box( "Cal", Perf_cal )
	)
);
tb << Set Selectable Rows( 1 );
tb << Get Selected Rows;

View solution in original post

0 Kudos
4 REPLIES 4
ih
ih
Community Trekker

Re: List box ignores the duplicate items from list !!

I am not sure about the specific list box question but I wonder if a table box would accomplish your goal.

Perf_cal = {"101.6", "100.8", "100.8", "100.2", "101", "101.8", "100", "99.2"};
Perf_item = {"a", "b", "c", "d", "e", "f", "g", "h"};
New window("new",
	tb = Table box(
		String Col Box( "Item", Perf_item ),
		String Col Box( "Cal", Perf_cal )
	)
);
tb << Set Selectable Rows( 1 );
tb << Get Selected Rows;

View solution in original post

0 Kudos
ram_asra_gmail_
Community Trekker

Re: List box ignores the duplicate items from list !!

well, to use string col box, table box is not necessary. i did not use string col box, bcoz, individual items are not slectable. But thanks for lookin at it.
0 Kudos
ih
ih
Community Trekker

Re: List box ignores the duplicate items from list !!

The table box and << Set Selectable Rows message is what allows you to select individual items.  Depending if you want to select the item and cal together, here are two ways to build the window:

table box.PNG

Names Default to Here( 1 );

Perf_cal = {"101.6", "100.8", "100.8", "100.2", "101", "101.8", "100", "99.2"};
Perf_item = {"a", "b", "c", "d", "e", "f", "g", "h"};

New window("new",
	H List Box(
		tb1 = Table box(
			String Col Box( "Item", Perf_item ),
			String Col Box( "Cal", Perf_cal )
		),
		spacerbox( size( 10, 10 ) ),
		tb2 = Table box(
			String Col Box( "Item", Perf_item )
		),
		tb3 = Table box(
			String Col Box( "Cal", Perf_cal )
		),
		<<Padding(5)
		
	)
);

//Make rows selectable
{ tb1, tb2, tb3 } << Set Selectable Rows( 1 );

//Get selected rows
tb1 << Get Selected Rows; //Returns [1] for the screenshot above
tb2 << Get Selected Rows; //Returns [2] for the screenshot above
tb3 << Get Selected Rows; //Returns [3] for the screenshot above

 

pmroz
Super User

Re: List box ignores the duplicate items from list !!

Another approach you can do is to make perf_cal unique by prepending perf_item to it.  When a user makes a selection you'll need to strip off the first three characters.

Perf_cal = {"101.6", "100.8", "100.8", "100.2", "101", "101.8", "100", "99.2"};
Perf_item = {"a", "b", "c", "d", "e", "f", "g", "h"};

perf_list = {};
for (i = 1, i <= nitems(perf_cal), i++,
	perf_list[i] = perf_item[i] || ". " || perf_cal[i];
);

New Window( "new",
	perf = H List Box(
		List Box( Perf_list, width( 50 ), nlines( 8 ) )
	);
);