11-03-2006, 06:48 AM
Function CB_InitDialogVariable
;/
function# str&cbVar selItem
;To initialize a combo box, before ShowDialog you assign a list of items to the variable, eg cb3="item0[]item1[]item2".
;To select an item, is used & at the beginning of the line, eg cb3="item0[]&item1[]item2".
;This function inserts & into cbVar so that item selItem would be selected.
;Returns 1 if successful, 0 if selItem is invalid.
;cbVar - combo box variable. Should not have lines that begin with &.
;selItem - 0-based item index.
;EXAMPLE
;str controls = "3"
;str cb3
;cb3="item 0[]item 1[]item 2"
;int i; rget i "cb" "\MyAppName" 0 0; if(i>2) i=2
;CB_InitDialogVariable cb3 i
;if(!ShowDialog("" 0 &controls)) ret
;i=val(cb3); rset i "cb" "\MyAppName" 0 0
ARRAY(str) a=cbVar
a[selItem]-"&"; err ret
cbVar=a
ret 1