Re: switch bug?

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

[quote Jeremy Cowgar]

irv said...
	switch result do 
		case 0 : puts(1,"Quit button clicked\n")  
		case 1 : puts(1,"OK button clicked\n")  
		case -4 : puts(1,"You closed the window\n")  
		case else ? result 
	end switch 

Just a note, however, you do have a slight problem in your code. Case statements will fall through.

You need to introduce break at the end of each case:

switch result do 
    case 0 :  
        puts(1,"Quit button clicked\n")  
        break 
 
    case 1 :  
        puts(1,"OK button clicked\n")  
        break 
 
    case -4 :  
        puts(1,"You closed the window\n")  
        break 
 
    case else  
        ? result 
end switch 

Can we also have the select statement, that doesn't fall through.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu