PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Selecting all list_box entries  (Read 256 times)

James Zukowski

  • Diamond Member
  • *****
  • Posts: 102
    • View Profile
Selecting all list_box entries
« on: September 18, 2019, 02:25:15 PM »
Does anyone have an easy way to programmatically select all of the entries in a list_box?
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

RobL

  • Member
  • **
  • Posts: 6
    • View Profile
Re: Selecting all list_box entries
« Reply #1 on: September 19, 2019, 01:02:13 AM »
Hi James,

I found the following in an email posted by Mike King (dated 12/03/2007) on the old PxPlus Mailing List.

<snip>
If you happen to be using PxPlus use the FIND option to read all the values then issue a WRITE to enable them.

For example:

0010 LIST_BOX 10,@(10,5,40,10),OPT="#"
0020 FOR I=1 TO 50
0030 LIST_BOX LOAD 10,0,STR(RND(10000):"0000")+STR(RND(10000):"0000")
0040 NEXT I
0050 LIST_BOX FIND 10,0,X$
0060 LIST_BOX WRITE 10,X$
0070 ESCAPE

The FIND on line 50 gets a string containing all the values, then you can write this back to the control in order to select all the items.

... so basically all you need to do is:

LIST_BOX FIND 10,0,X$
LIST_BOX WRITE 10,X$
</snip>

Is that what you're looking for?

Regards,

Rob Leighton
Riverwood Enterprises Inc.

James Zukowski

  • Diamond Member
  • *****
  • Posts: 102
    • View Profile
Re: Selecting all list_box entries
« Reply #2 on: September 19, 2019, 09:56:19 AM »
Thank you!
That definitely is much better than the for/next loop I was using to write each one individually.
Now, if there was something as easy as list_box write x,0 that clears them all...
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

David Reynolds

  • Member
  • **
  • Posts: 11
    • View Profile
Re: Selecting all list_box entries
« Reply #3 on: September 19, 2019, 10:51:20 AM »
James,

You should simply be able to issue a

LBCTL'SelectCount=0

to deselect everything.

David

James Zukowski

  • Diamond Member
  • *****
  • Posts: 102
    • View Profile
Re: Selecting all list_box entries
« Reply #4 on: September 19, 2019, 10:59:28 AM »
Either way will work. Just looking for something analagous to set them all.
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3185
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Selecting all list_box entries
« Reply #5 on: September 19, 2019, 04:29:39 PM »
James,  your message seemed to indicate you want to select ALL the entries.  Is that what you were looking for or did you merely want to read the selected entries.

James Zukowski

  • Diamond Member
  • *****
  • Posts: 102
    • View Profile
Re: Selecting all list_box entries
« Reply #6 on: September 19, 2019, 05:11:13 PM »
I am looking to select them all. We're using this to set up some selection criteria where the normal situation is to start with everything, but they have the option to reduce it from there.
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

ksproul

  • Silver Member
  • ***
  • Posts: 20
    • View Profile
Re: Selecting all list_box entries
« Reply #7 on: September 19, 2019, 09:33:25 PM »
If the data in the list box is large, reading and writing it to select everything may be time consuming, especially in a client/server environment.  An example with 5,000 items in the list using an alternative method is shown below.  Un-remark line 220 to see the difference in time using the read/write method.  In my tests over a client/server internet (not intranet) connection took almost 4 times longer to select all of the items using the read/write method.

0010 begin
0015 print 'CS',
0020 precision 8
0025 list_box 10,@(10,5,40,10),opt="#"
0030 print "Loading ... ",; wait 0; t=tim
0035 for i=1 to 5000
0040 list_box load 10,0,str(rnd(10000):"0000")+str(rnd(10000):"0000")
0045 next i
0050 print @(0),"elapsted seconds:",(tim-t)*3600; wait 0
0055 print "Selecting ... ",; wait 0; t=tim
0060 selected=fn_lb_select_all(10)
0065 print "elapsed seconds:",(tim-t)*3600; wait 0
0070 list_box goto 10
0075 obtain "Press Enter to end",*,'LF'
0080 list_box remove 10
0085 end

0200 def fn_lb_select_all(local id)
0205 local items=id'itemcount,i,p$,v$
0210 if items then {
0215 list_box hide id
0220 ! list_box find 10,0,x$; list_box write 10,x$; goto 0235
0225 for i=items to 1 step -1; p$+=",selectitem",v$+=sep+str(i); next i
0230 id'_proplist$=p$(2),id'_propvalues$=v$(2)
0235 list_box show id
0240  }
0245 return items
0250 end def
Ken Sproul
DPI Information Services, Inc.

James Zukowski

  • Diamond Member
  • *****
  • Posts: 102
    • View Profile
Re: Selecting all list_box entries
« Reply #8 on: September 20, 2019, 09:45:46 AM »
Fortunately, in our case, we're only dealing with a couple of hundred entries max in 3 lists, so it's going to be quick whichever way we go. The for/write/next was visible, since I didn't hide the list_box first, and it looked a little flashy. Using the find/write all works really well in this situation.
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3185
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Selecting all list_box entries
« Reply #9 on: September 20, 2019, 03:12:02 PM »
James

To select ALL entries try:

LIST_BOX FIND lbHandle, 0, allItems$
LIST_BOX WRITE lbHandle, allItems$

James Zukowski

  • Diamond Member
  • *****
  • Posts: 102
    • View Profile
Re: Selecting all list_box entries
« Reply #10 on: September 20, 2019, 03:32:31 PM »
That's basically what I got from RobL above, and it works fine. Just looking for the easier (as usual).
James Zukowski
Programmer / ERP Analyst
Beauty Enterprises, Inc.
150 Meadow St.
Hartford, CT 06114
860.296.9303  Ext 231

ksproul

  • Silver Member
  • ***
  • Posts: 20
    • View Profile
Re: Selecting all list_box entries
« Reply #11 on: September 20, 2019, 04:03:53 PM »
Mike, maybe you could add a select all method that does the same thing as ctrl-a.  :)
Ken Sproul
DPI Information Services, Inc.