Jump to content

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


 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

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...