| View previous topic :: View next topic |
| Author |
Message |
Sakurako
Joined: 10 May 2007 Posts: 142
|
Posted: Thu Mar 13, 2008 9:08 am Post subject: Function RegExMatch() BUG? |
|
|
| 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 |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1133 Location: Denmark
|
Posted: Thu Mar 13, 2008 9:11 am Post subject: |
|
|
| 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 |
|
 |
Sakurako
Joined: 10 May 2007 Posts: 142
|
Posted: Thu Mar 13, 2008 9:14 am Post subject: |
|
|
| 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 |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2364 Location: Australia, Qld
|
Posted: Sun Mar 16, 2008 3:25 pm Post subject: |
|
|
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 |
|
 |
|