Post by hal9k on Jun 18, 2023 16:36:30 GMT -5
I have a large LB program that I'm writing to help my wife manage her garden. In testing, I'm finding a seemingly random problem. There is a combobox that contains the possible numeric values for a date computation. There is a textbox that contains the season - either "S" or "F". There is a second textbox that is set to disabled to prevent user entry. The result of the date computation is displayed in this textbox. The code looks something like this:
print #test.combo1, "contents? weeks$"
print #test.text1, "!contents? season$"
season$ = upper$(season$)
gosub [getDate] 'compute date based upon season4 and weeks$
print #test.text2, target$
wait
print #test.text1, "!contents? season$"
season$ = upper$(season$)
gosub [getDate] 'compute date based upon season4 and weeks$
print #test.text2, target$
wait
This works just fine about 90% of the time. The rest of the time the second text box doesn't get filled with the results of the date computation done in the getDate routine. When this happens, if I select the same value from the combobox it typically fails. If I select a different value, it typically works. Then I select the original value and it works the way it should have all along.
The obvious culprit is the [getData] subroutine. It is very small and does NOTHING except look at season$ and week$, do a simple date calculation, and put the result in a variable called target$. It doesn't reference any of the gui controls or branch off anywhere.
This is very weird and, as mentioned, it doesn't happen very often. I've added debug code and haven't seen any indication of why it would fail. Before I put in a lot more time debugging, I wanted ask the experts if there is anything special about comboboxes that I should know that might help me figure out why this is happening and how I might be able to avoid it. At first I thought that the code above was not always firing, but after watching a lot of traces, it appears to always fire. Just sometimes the value returned from [getDate] doesn't get displayed in the second textbox.
I'll keep playing with it, but if anybody has an idea of what I'm doing wrong or why a combobox might occasionally take a break, I'd appreciate your input.
Thanks!