Re: Switch Bug

new topic     » goto parent     » topic index » view thread      » older message » newer message
mindwalker said...

I'm not sure I know what I'm talking about, but I think you need a break statement at the end of each case. Otherwise I think it executes all the cases starting at the one that matches. So for example in your code if id is equal to wxID_SAVE then I think message is getting set to "Save" then to "Save As" followed by "Print Setup" all the way down to "Exit".

So add a line that reads break after each message = ... line. For example:

case wxID_OPEN then 
    message = "Open" 
    break 

I thought of that too, at first; in fact I tried it and it had no effect. The break command should only be necessary when also using with fallthru. From the manual:

manual said...

By default, control flows to the end of the switch block when the next case is encountered. The default behavior can be modified in two ways. The default for a particular switch block can be changed so that control passes to the next executable statement whenever a new case is encountered by using with fallthru in the switch statement:

switch x with fallthru do 
    case 1 then 
        ? 1 
    case 2 then 
        ? 2 
        break 
    case else 
        ? 0 
end switch 

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu