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