|
Post by meerkat on Mar 1, 2019 11:56:00 GMT -5
I have a combobox as:
Combobox #main.cdb, dbsFile$(), [shoTblsGo] ,010,120,220,224
Code for selecting the combobox [shoTblsGo] #main.cdb "selectionindex? curDbIdx"
print "curDbIdx ";curDbIdx
wait
I always get curDbIdx = 0
So what is the correct syntax to get the index number of the selected item?
Thanks for the help.. Dan
|
|
|
Post by Carl Gundel on Mar 1, 2019 12:10:25 GMT -5
So what is the correct syntax to get the index number of the selected item? Thanks for the help.. Dan LB5 style is: curDbIdx = #main.cbd selectionindex()
|
|
|
Post by meerkat on Mar 1, 2019 12:58:22 GMT -5
So what is the correct syntax to get the index number of the selected item? Thanks for the help.. Dan LB5 style is: curDbIdx = #main.cbd selectionindex() Thanks Carl; Like the new style.. But I still get 0 no matter what I select. This new style works: x$ = #main.cdb selection$()
|
|
|
Post by Rod on Mar 1, 2019 13:08:43 GMT -5
Can we have some runnable code to test?
|
|
|
Post by Carl Gundel on Mar 1, 2019 13:14:06 GMT -5
Thanks Carl; Like the new style.. But I still get 0 no matter what I select. This new style works: x$ = #main.cdb selection$() This doesn't work? dim maker$(5) maker$(0) = "Tandy" maker$(1) = "Commodore" maker$(2) = "Atari" maker$(3) = "Sinclair" maker$(4) = "Apple" maker$(5) = "IBM"
combobox #main.cbox, maker$(, [selected], 10, 10, 160, 25 open "selectionindex() example" for window as #main wait
[selected] idx = #main.cbox selectionindex() print idx wait
|
|
|
Post by meerkat on Mar 1, 2019 13:56:30 GMT -5
Here is a small test program that works:
dim dbsFile$(10) for i = 1 to 10 dbsFile$(i) = "File ";i next i WindowWidth = 300 WindowHeight = 200 UpperLeftX = 200 UpperLeftY = 200
statictext #main, "___ Test ____" ,010,010,200,030 combobox #main.cdb, dbsFile$(), [shoTblsGo] ,010,020,120,124
open "Test combobox" for window_nf as #main #main "trapclose [exit]" #main "font arial 12 bold" wait
[shoTblsGo] curDbIdx = #main.cdb selectionindex() x$ = #main.cdb selection$() ' what was selected notice "Index: ";curDbIdx;" ";x$ wait
[exit] close #main end
The program I'm testing is about 1100 lines so I don't think posting it will help.
I'm trying all the obvious stuff like duplicate #main.cdb. I'm bypassing and cutting code to find out at what point it starts to work correctly. Will take some time.
|
|
|
Post by Carl Gundel on Mar 1, 2019 14:47:28 GMT -5
Here is a small test program that works: The example I posted didn't work? ;-)
|
|
|
Post by meerkat on Mar 1, 2019 15:08:04 GMT -5
Maybe I don't have the proper reload command. Is there docs on LB5?
This gives me 0 again.. Note the gosub [makMaker]. I have a routine that fills the combo array. That's because the info in the array can change. Thanks for the help.. Dan.
dim maker$(5) maker$(0) = "Tandy" maker$(1) = "Commodore" maker$(2) = "Atari" maker$(3) = "Sinclair" maker$(4) = "Apple" maker$(5) = "IBM"
combobox #main.cbox, maker$(, [selected], 10, 10, 160, 25 open "selectionindex() example" for window as #main gosub [makMaker] wait
[selected] idx = #main.cbox selectionindex() print idx wait
[makMaker] for i = 1 to 5 maker$(i) = "maker_";i next i #main.cbox "reload" return
|
|
|
Post by Carl Gundel on Mar 1, 2019 15:11:34 GMT -5
Maybe I don't have the proper reload command. Is there docs on LB5? This gives me 0 again.. Note the gosub [makMaker]. I have a routine that fills the combo array. That's because the info in the array can change. Thanks for the help.. Dan. Huh. I think you found a bug.
|
|
|
Post by Rod on Mar 1, 2019 15:28:42 GMT -5
I have a vague recollection that reload needs a scan or event for the change to be noted in the combobox, Will experiment tomorrow.
|
|
|
Post by metro on Mar 1, 2019 18:15:38 GMT -5
[makMaker] for i = 1 to 5 maker$(i) = "maker_";i next i #main.cbox "reload" return
Following the new coding paradigm should it read #main.cbox reload()
|
|
|
Post by meerkat on Mar 1, 2019 19:40:13 GMT -5
[makMaker] for i = 1 to 5 maker$(i) = "maker_";i next i #main.cbox "reload" return
Following the new coding paradigm should it read #main.cbox reload() Thanks Laurie.. Ya! I agree.. I tried them both. I want back to LB4 syntax just to see. Both give the same results. Took me a while to figure out what was going on. Some worked and some didn't. Al depended on if it was changed and reloaded. I like the new syntax..
|
|