I tend to use list boxes alot, usually through table.external_record_content_get() lists or others. I got tired of constantly writing a display for the lists, so I generated a UDF that works very well. I thought I would shared it. It automatically adjusts to input list length and list item width.
Hope it is helpfulto some.
Hope it is helpfulto some.
Code:
FUNCTION list_box_auto as V (dbxTitle as C, vInput as C) dim global vproceed as C dim shared vinput as C = "" dim shared voutput as C ="" dim shared dbxL as c dim shared venum as N venum = w_count(vinput,crlf()) if venum > 25 venum = 25 end if dim shared vwide as N dim shared dbxTitle as C dim z1 as C dim z3 as C dim vdlgF as C '==== this must be in code prior to running this to get width ======= dim vwlp as n=0 ' Word Length Prior dim vwln as n=0 ' Word Length Now dim vwlF as N ' Word Length Final dim vfv as C ' Foo Value for each foo in vinput vfv = foo.value vwln = len(vfv) ' Word Length Now if vwln > vwlp then ' Word Length Now - Word Length Prior vwlF = vwln ' Word Length Final = Word Length Now end if vwlp = vwln next vwlF = (vwlF) * 1.6 ' Word Length Final + 5 by factor for bold font '===================================================================== RELIST: z1 = <<%dg1% {background=#185,175,135} {font=Arial,10,B} {lf}; {region} %dg1% z3 = <<%dg3% voutput^#vinput]; {lf}; {endregion}; {line=1,0}; {region2} {justify=center}<*15&OK!OK> <15&Cancel!CANCEL> {endregion2};%dg3% vdlgF = z1 + (""+"[."+vwlF+","+venum) + z3 dbxL = ui_dlg_box(dbxTitle,vdlgF) SELECT CASE dbxL = "Cancel" vproceed = "no" end CASE dbxL = "OK" vproceed = "yes" if voutput = "" ui_modeless_dlg_box("Message",<<%dlg% {background=#220,220,220} {region1} {endregion1}; {region2} NO SELECTION WAS MADE ; {endregion2}; {region3} {endregion3}; %dlg%) xbasic_wait_for_idle() sleep(1.8) ui_modeless_dlg_close("Message") GOTO RELIST end if END SELECT END FUNCTION
Comment