Could some kinda coder please try out my code and test it
Posted: Wed Jul 12, 2006 6:27 pm
Hi there, Please could someone copy and paste the following code into Purebasic 4, run it and test it please. The problem is that, if you run the code, select option Test 1, and select "Test Button" it works for the first time, as you will get a debug. But if you select Test 2 and select "Test Button", then it does work, but you also get the messagerequester box, and I'm not sure why. The messagerequester is only suppose to appear, if you haven't selected any option, and selected "Test Button"
Here is the code:
Many thanks in advance who can help out 
Here is the code:
Code: Select all
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Radio_0
#Radio_1
#Radio_2
#Frame3D_0
#Button_0
#Button_1
EndEnumeration
;- StatusBar Constants
;
Enumeration
#StatusBar_0
EndEnumeration
Procedure Open_Window_0()
If OpenWindow(#Window_0, 258, 212, 277, 162, "Test Application", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
If CreateStatusBar(#StatusBar_0, WindowID(#Window_0))
EndIf
If CreateGadgetList(WindowID(#Window_0))
OptionGadget(#Radio_0, 16, 32, 120, 30, "Test 1")
GadgetToolTip(#Radio_0, "Check Test 1")
OptionGadget(#Radio_1, 16, 60, 120, 30, "Test 2")
GadgetToolTip(#Radio_1, "Check Test 2")
OptionGadget(#Radio_2, 16, 92, 120, 30, "Test 3")
GadgetToolTip(#Radio_2, "Check Test 3")
ButtonGadget(#Button_0, 184, 20, 76, 28, "Test Button")
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_Event_Gadget
If GetGadgetState(#Radio_0)=1 And GadgetID=#Button_0 : Debug "Test 1 - Success" : EndIf
If GetGadgetState(#Radio_1)=1 And GadgetID=#Button_0 : Debug "Test 2 - Success" : EndIf
If GetGadgetState(#Radio_2)=1 And GadgetID=#Button_0 : Debug "Test 3 - Success" : EndIf
If GadgetID = #Button_0 And GetGadgetState(#Radio_0)=0 Or GetGadgetState(#Radio_1)=0 Or GetGadgetState(#Radio_2)=0 : MessageRequester("Error","Nothin has been selected",#PB_MessageRequester_Ok) : EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
End