For some reason I encounter bugs that seem to have no rational explanation.
This one is a lulu. I am working on a rather elementary program for
calculating compound interest. It contains the following function to create
a menu from which the user can select an interest rate:
LOCAL FN buildmenus
MENU 1,0,_enable ,"File"
MENU 1,1,_enable,"Quit/Q"
MENU 2,0,1, "Interest Rate"
MENU 2,1,1, "2%"
MENU 2,2,1, "2.5%"
MENU 2,3,1, "3%"
MENU 2,4,1, "3.5%"
MENU 2,5,_checked, "4%"
MENU 2,6,1, "4.5%"
MENU 2,7,1, "5%"
MENU 2,8,1, "5.5%"
MENU 2,9,1, "6%"
itemchecked = 5
rate = .04
end fn
The function that processes a menu click looks like this:
LOCAL
DIM menuID
DIM itemID
DIM thisitem
LOCAL FN menuprocess
menuID = MENU(_menuID)
itemID = MENU(_itemID)
SELECT menuID
CASE 1 'quit
FN Quit
CASE 2 'interest rate
FOR thisitem = 1 to 9
if thisitem = itemchecked then menu 2,thisitem,1 'uncheck the
previously checked item
NEXT
SELECT itemID
CASE 1
rate! = .02
MENU 2,1,_checked
CASE 2
rate! = .025
MENU 2,2,_checked
CASE 3
rate! = .03
MENU 2,3,_checked
CASE 4
rate! = .035
MENU 2,4,_checked
CASE 5
rate! = .04
MENU 2,5,_checked
CASE 6
BEEP
rate! = .045
MENU 2,6,_checked
CASE 7
rate! = .05
MENU 2,7,_checked
CASE 8
rate! = .055
MENU 2,8,_checked
case 9
rate! = .06
MENU 2,9,_checked
END SELECT
END SELECT
itemchecked = itemID
MENU
end fn
Pretty straightforward stuff, right?
However, I've found that when the user chooses any of the interest rates
3%, 3.5%, 4%, or 4.5%, the menu does not respond. In fact, using a BEEP, I
find that the CASE for the given rate is not recognized at all. The other
rates are recognized OK. By a lengthy process of trial and error, I've
narrowed down the conflict to the following two statements (from a function
that builds the single window in the program):
EDIT FIELD #6,"1", (440, 310)-(500, 330),_FramedNoCR ' for user to enter
duration of investment
EDIT FIELD #4,"100", (440, 230)-(500, 245), _FramedNoCR' for user to enter
starting principal
If I change the two edit fields to _Statnoframed, the problem disappears.
But I want the edit fields "editable!"
I haven't a clue as to what's going on here. Why would the nature of an
edit field interfere with the ability to choose some menu items. Can anyone
help me here?
TIA
Richard Goodman