Blue_Drache Posted September 7, 2006 Share Posted September 7, 2006 (edited) Ever have one of those days? Opt("MustDeclareVars",1) ; <snip> ScanRoute() ; <snip> Func ScanRoute($option = "") If Not IsDeclared($jul) then Local $jul ; <snip> EndFunc ----------------------------------------------------------------------------- C:\Documents and Settings\U256655\Desktop\AutoIt\User Scripts\ScanRoute-GUI.au3 (642) : ==> Variable used without being declared.: If Not IsDeclared($jul) then Local $jul if Not IsDeclared(^ ERROR It's probably "expected behaviour", but it's amusing none the less. Edited September 7, 2006 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
marfdaman Posted September 7, 2006 Share Posted September 7, 2006 It's completely expected, IsDeclared goes with strings, not variables. So: IsDeclared("jul")should do it. Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Link to comment Share on other sites More sharing options...
Blue_Drache Posted September 7, 2006 Author Share Posted September 7, 2006 It's completely expected, IsDeclared goes with strings, not variables. So: IsDeclared("jul")should do it. In your debt, thank you. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Valik Posted September 7, 2006 Share Posted September 7, 2006 (edited) The code should be:If Not IsDeclared("jul") then Assign("jul", "", 1)Never mix variables and the pseudo-pointer functionality provided by Assign(), Eval() and IsDeclared().Edit: And everywhere you try to access the variable $jul, you should use Eval(). If you use $jul explicitly anywhere, you've got a design flaw. Edited September 7, 2006 by Valik Link to comment Share on other sites More sharing options...
Blue_Drache Posted September 7, 2006 Author Share Posted September 7, 2006 (edited) The code should be: If Not IsDeclared("jul") then Assign("jul", "", 1) Never mix variables and the pseudo-pointer functionality provided by Assign(), Eval() and IsDeclared(). Edit: And everywhere you try to access the variable $jul, you should use Eval(). If you use $jul explicitly anywhere, you've got a design flaw. Not quite sure if I understand the difference between a variable and a "pseudo-pointer" in the first place. Can you please either elaborate or point to a resource that can enlighten? Edited September 7, 2006 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Valik Posted September 7, 2006 Share Posted September 7, 2006 It's not really relevant. What's important is to ask yourself this: Do I know the name of the variable at design time? If the answer is "yes", you do not need to use Assign(), Eval() or IsDeclared() at all. In your case, you seem to know that the variable is going to be named $jul. So what are you trying to accomplish with your original code? What did you hope to achieve by conditionally creating the variable? The way the code is written (Even the corrected way I showed), the variable $jul is going to be created every time ScanRoute() is called. If that was your intent, then simply using "Local $jul" and skipping the IsDeclared() part would be sufficient. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now