AutoHotkey Community

It is currently May 27th, 2012, 9:03 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: if statement bug [AHK_L]
PostPosted: October 17th, 2011, 3:11 pm 
Offline

Joined: July 27th, 2011, 5:20 pm
Posts: 109
I discussed the issue in multiple posts at http://www.autohotkey.com/forum/viewtop ... 763#482763 already, but somebody requested I post it here as well:

"I have this code in my script that worked fine until updating from 1.1.0.4.00 to 1.1.0.5.01:
Code:
if (Tag = "")
     global Tag := pWin.document.all["s_1_1_46_0"].value

Now when this script runs, I get an error stating "Error: Declaration conflicts with existing var." The problem appears to be that the if statement is being recognized as a declaration (commenting the IF out eliminates the problem.) This seems to me like an error with AHK_L rather than something I'm doing wrong, but maybe I'm incorrect. Any advice for this?"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2011, 3:37 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I'm not sure if you can conditionally declare super-global variables (if this is not inside a function, that is).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2011, 3:45 pm 
Offline

Joined: July 27th, 2011, 5:20 pm
Posts: 109
fragman wrote:
I'm not sure if you can conditionally declare super-global variables (if this is not inside a function, that is).


It is inside a function, yes. Also, this was working perfectly on the previous version I mentioned.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 17th, 2011, 6:15 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
i expect that it was actually a bug in the older version, but Lexikos will be the one to tell you for sure. I would expect you have to declare it Global before the if statement.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2011, 3:39 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
This behaviour is by design, intended to help catch bugs. The reference to "Tag" on the first line resolves to a local variable because it has not yet been declared global. When the conflicting declaration is encountered on the next line, it is treated as an error. Older versions tolerated conflicting declarations.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group