Sign in to follow this  
Followers 0
Phaser

Radio messages

4 posts in this topic

Hi everyone

I need to set 3 options via radio buttons to set $mode

#include <GUIConstantsEx.au3>

HotKeySet("{ESC}", "killit")

Opt("GUIOnEventMode", 1)
GUICreate("Data Tool", 340, 130)
GUISetOnEvent($GUI_EVENT_CLOSE, "killit")
GUICtrlCreateLabel("Start?", 150, 35)
$okbutton = GUICtrlCreateButton("Yes", 152, 70, 60)
GUICtrlSetOnEvent($okbutton, "goforit")
$cancelbutton = GUICtrlCreateButton("Close", 245, 70, 60)
GUICtrlSetOnEvent($cancelbutton, "killit")
$checkbox = GUICtrlCreateCheckbox("Tick to stop", 240, 33, 120, 20)
GuiCtrlCreateGroup("Select Mode", 20, 10,110,110)
$radio1 = GuiCtrlCreateRadio("Soft", 40, 30, 80)
GuiCtrlSetState($radio1, $GUI_CHECKED)
$radio2 = GuiCtrlCreateRadio("Medium", 40, 55, 80)
$radio3 = GuiCtrlCreateRadio("Hard", 40, 80, 80)
GUICtrlCreateGroup ("",-99,-99,1,1)
GUISetState()

$msg = GUIGetMsg()
Select
Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
     $mode = 1
Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED
     $mode = 2
Case $msg = $radio3 And BitAND(GUICtrlRead($radio3), $GUI_CHECKED) = $GUI_CHECKED
     $mode = 3
EndSelect

Global $mode,$radio1,$radio2,$radio3


While 1
  Sleep(1000)
WEnd

Func goforit()
While 1; the main loop, everything happens within here

MsgBox(0,"box name", "Mode " & $mode,2)

    
;check if we need to stop
if BitAnd(GUICtrlRead($checkbox), $GUI_CHECKED) = True Then
    ExitLoop
EndIf

WEnd ; end of main loop

EndFunc

Func killit()
    Exit
EndFunc

I have tried a few different ways but don't get any response? hopefully someone can see where I went wrong, the $mode value needs to be global as it is called via an included file.

Share this post


Link to post
Share on other sites



Hi,

like this? Only the 1.st part until Function goforit.

#include <GUIConstantsEx.au3>

HotKeySet("{ESC}", "killit")
Global $mode,$radio1,$radio2,$radio3

Opt("GUIOnEventMode", 1)
GUICreate("Data Tool", 340, 130)
GUISetOnEvent($GUI_EVENT_CLOSE, "killit")
GUICtrlCreateLabel("Start?", 150, 35)
$okbutton = GUICtrlCreateButton("Yes", 152, 70, 60)
GUICtrlSetOnEvent($okbutton, "goforit")
$cancelbutton = GUICtrlCreateButton("Close", 245, 70, 60)
GUICtrlSetOnEvent($cancelbutton, "killit")
$checkbox = GUICtrlCreateCheckbox("Tick to stop", 240, 33, 120, 20)
GuiCtrlCreateGroup("Select Mode", 20, 10,110,110)
$radio1 = GuiCtrlCreateRadio("Soft", 40, 30, 80)
GuiCtrlSetState($radio1, $GUI_CHECKED)
$radio2 = GuiCtrlCreateRadio("Medium", 40, 55, 80)
$radio3 = GuiCtrlCreateRadio("Hard", 40, 80, 80)
GUICtrlCreateGroup ("",-99,-99,1,1)
GUISetState()

$msg = GUIGetMsg()

While 1
    Select
        Case GUICtrlRead($radio1) = $GUI_CHECKED
             $mode = 1
        Case GUICtrlRead($radio2) = $GUI_CHECKED
             $mode = 2
        Case GUICtrlRead($radio3) = $GUI_CHECKED
             $mode = 3
    EndSelect
    Sleep(1000)
    ConsoleWrite ($mode); Only for debugging......
WEnd

;-))

Share this post


Link to post
Share on other sites

Thanks 99ojo, glad to see I was sort of almost there

Share this post


Link to post
Share on other sites

Here:

#include <GUIConstantsEx.au3>

HotKeySet("{ESC}", "killit")

;Opt("GUIOnEventMode", 1)
GUICreate("Data Tool", 340, 130)
;GUISetOnEvent($GUI_EVENT_CLOSE, "killit")
GUICtrlCreateLabel("Start?", 150, 35)
$okbutton = GUICtrlCreateButton("Yes", 152, 70, 60)
;GUICtrlSetOnEvent($okbutton, "goforit")
$cancelbutton = GUICtrlCreateButton("Close", 245, 70, 60)
GUICtrlSetOnEvent($cancelbutton, "killit")
$checkbox = GUICtrlCreateCheckbox("Tick to stop", 240, 33, 120, 20)
GuiCtrlCreateGroup("Select Mode", 20, 10,110,110)
$radio1 = GuiCtrlCreateRadio("Soft", 40, 30, 80)
GuiCtrlSetState($radio1, $GUI_CHECKED)
$radio2 = GuiCtrlCreateRadio("Medium", 40, 55, 80)
$radio3 = GuiCtrlCreateRadio("Hard", 40, 80, 80)
GUICtrlCreateGroup ("",-99,-99,1,1)
GUISetState()


GUISetState(@sw_show)
Global $mode,$radio1,$radio2,$radio3


While 1
    $msg = GUIGetMsg()
Switch $msg
Case $gui_event_close
    killit()
Case $okbutton
    if BitAnd(GUICtrlRead($checkbox), $GUI_CHECKED) = True Then
    ExitLoop
    EndIf
    
    For $i=1 to 3
        $rad=eval("radio"&$i)
        If GUICtrlRead($rad)=$gui_checked Then 
            $mode=$i
            MsgBox(0,"box name", "Mode " & $mode,2)
        EndIf
    Next
EndSwitch

WEnd


Func killit()
    Exit
EndFunc

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0