Jump to content
Sign in to follow this  
Rad

If IsDeclared("MyVar") always false >.>

Recommended Posts

Rad

Au3 Example:

If IsDeclared ("a") then
    MsgBox(0,"", "$a IS declared"  )     ; due to previous $a=1 assignment
EndIf

Mine:

If IsDeclared("WindowsMax") then
        MsgBox(0,"", "$WindowsMax IS declared"  )    ; due to previous $a=1 assignment
    Else
        MsgBox(0,"", "$WindowsMax is NOT declared"  )    ; due to previous $a=1 assignment
    EndIf
    $WindowsMax = $ii

This is mainly to determine if the function has run yet, but I have a few other uses for IsDeclared I just discovered... but it doesnt work! Even if I run the function twice it doesnt work, whats wrong?

It always says its not declared <,<

Now that I read this below, I tried this:

Success: Returns 1 for Global variable or variable declared outside functions. 
Special: -1 for Local variable. 
Failure: Return 0 when no variable can be found. 

$test = IsDeclared("WindowsMax")
Msgbox(0,"test",$test)
$WindowsMax = $ii

Still only returns 0 >.>

$ii works though

Share this post


Link to post
Share on other sites
OverloadUT

In both of your examples, you're declaring the variable AFTER you call "IsDeclared" so it's functioning exactly as expected.

If this just a snippit of your code? If it is, post the whole thing, or at least the entirety of an example so we can see.

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.