Jump to content

Gui Vars Not Saved


ondrajka
 Share

Recommended Posts

Cant seem to get it to save the $click var. After a button is pressed you get a yes or no was pressed msgbox. Click on ok and you get Error: varible used without being declared.

#include <GUIConstantsEx.au3>

Example()

Func Example()

Local $Button_1, $Button_2, $msg

GUICreate("Yes No Box", 220, 75)

Opt("GUICoordMode", 2)

$Button_1 = GUICtrlCreateButton("Yes", 10, 30, 100)

$Button_2 = GUICtrlCreateButton("No", 0, -1)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Button_1

MsgBox(0, 'Testing', 'Yes was pressed')

$click="Yes"

ExitLoop

Case $msg = $Button_2

MsgBox(0, 'Testing', 'No was pressed')

$click="no"

ExitLoop

EndSelect

WEnd

GUIDelete()

EndFunc

MsgBox(0, 'After', $click)

Link to comment
Share on other sites

  • Developers

#include <GUIConstantsEx.au3>
Global $click
Example()
Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("Yes No Box", 220, 75)
    Opt("GUICoordMode", 2)
    $Button_1 = GUICtrlCreateButton("Yes", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton("No", 0, -1)
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                MsgBox(0, 'Testing', 'Yes was pressed')
                $click = "Yes"
                ExitLoop
            Case $msg = $Button_2
                MsgBox(0, 'Testing', 'No was pressed')
                $click = "no"
                ExitLoop
        EndSelect
    WEnd
    GUIDelete()
EndFunc  ;==>Example
MsgBox(0, 'After', $click)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...