Jump to content
Sign in to follow this  
ondrajka

Gui Vars Not Saved

Recommended Posts

ondrajka

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)

Share this post


Link to post
Share on other sites
Jos

#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)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×