Jump to content
Sign in to follow this  

Variable used without being declared

Recommended Posts



I want to check if a global variable is set or not and set from within the function.

Can someone help me why am I getting "Variable used without being declared." for "$CHECK"?

#include <GUIConstantsEx.au3>

AutoItSetOption('MustDeclareVars', 0)

GUICreate("DUMMY", 532, 450, -1, -1)


While 1
    $nMsg = GUIGetMsg()
        Switch $nMsg
        Case $GUI_EVENT_CLOSE
Func chk()
    If IsDeclared($CHECK) Then

Share this post

Link to post
Share on other sites

The code you have is sorta redundant with your Opt command. Delectation of vars is forced by you, this it is checked before the script is executed. IsDeclared is run time, it won't get that far due to the compiler compiler (AU3Check).

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post

Link to post
Share on other sites

Check the parameters for IsDeclared.

"string representing name of the variable to be checked." means:

IsDeclared($CHECK) ;IsDeclared would expect $CHECK to contain a string representation of a variable to evaluate, rather than evaluate $CHECK itsself. 
;should be

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.