Within a select statement you can make any number of identical case queries. Which of course leads to a faulty program.
Shouldn't the compiler detect this and report it?
Maybe I am wrong, maybe not?
I am curious about your opinion.
Code: Select all
;/-------------------------------------------------------------
;| This program demonstates the mentioned behavior.
;|
;| No help on the code needed.. :)
;|
;\-------------------------------------------------------------
EnableExplicit
#TIMER_DelayExecution = 0
If OpenWindow(0, 0, 0, 200, 100, "Window_Caption", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StickyWindow(0, 1)
ButtonGadget(0, 4, 4, 76, 20, "Click me")
AddWindowTimer(0, #TIMER_DelayExecution, 2000)
Repeat ; .. main loop
Select WaitWindowEvent(1000)
Case #PB_Event_None ; == 0
Debug "#PB_Event_None "
;>>> next line was my stupid error, but should that be detected by the compiler <<<
Case #TIMER_DelayExecution ; == 0
Debug "#TIMER_DelayExecution "
;>>> this is the correct implementation <<<
Case #PB_Event_Timer
Select EventTimer()
Case #TIMER_DelayExecution : Debug "#TIMER_DelayExecution "
EndSelect
;>>> this is just to show another case statements which are equal
Case #PB_All : Debug "#PB_All " + #PB_All ; == -1
Case #PB_Any : Debug "#PB_Any " + #PB_Any
Case #PB_Event_Gadget
Select EventGadget()
Case 0 : Debug "Button clicked "
EndSelect
Case #PB_Event_CloseWindow
Break ; close button on main window --> close application
EndSelect
ForEver
RemoveWindowTimer(0, #TIMER_DelayExecution)
EndIf