AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Function RegExMatch() BUG?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Sakurako



Joined: 10 May 2007
Posts: 142

PostPosted: Thu Mar 13, 2008 9:08 am    Post subject: Function RegExMatch() BUG? Reply with quote

Code:
Test := A_TickCount
Test()

Test()
{
 local Var1
 RegExMatch(Test, "(\d+)", Var)
listvars
pause
}
Code:
Test(Var = "")
{
 local Var1
 RegExMatch(Test, Var "(\d+)", Var)
listvars
pause
}

_________________


Last edited by Sakurako on Thu Mar 13, 2008 9:13 am; edited 1 time in total
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1133
Location: Denmark

PostPosted: Thu Mar 13, 2008 9:11 am    Post subject: Reply with quote

Quote:
All variables referenced or created inside a function are local by default (except built-in variables such as Clipboard, ErrorLevel, and A_TimeIdle). Each local variable's contents are visible only to lines that lie inside the function. Consequently, a local variable may have the same name as a global variable and both will have separate contents. Finally, all local variables start off blank each time the function is called.

Code:
Test := A_TickCount
Test()

Test()
{
 local Var1
 global Test
 RegExMatch(Test, "(\d+)", Var)
listvars
pause
}

_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
Sakurako



Joined: 10 May 2007
Posts: 142

PostPosted: Thu Mar 13, 2008 9:14 am    Post subject: Reply with quote

Quote:
If a function needs to reference or create a large number of global variables, it can be defined to assume that all its variables are global (except its parameters) by making its first line either the word "global" or the declaration of a local variable
P.S. tested... there would be error when adding "global Test" if already in global mode as the sample
_________________
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2364
Location: Australia, Qld

PostPosted: Sun Mar 16, 2008 3:25 pm    Post subject: Reply with quote

You have declared Var1 as local, but not Var.
Quote:
Within a function, to create an array that is global instead of local, declare the base name of the array (e.g. Match) as a global variable prior to using it. The converse is true for assume-global functions.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group