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 

sunroutine variables

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
playfullscientist



Joined: 20 Apr 2005
Posts: 22
Location: Princeton NJ USA

PostPosted: Fri Apr 22, 2005 8:47 pm    Post subject: sunroutine variables Reply with quote

Hi...Suppose you construct a subroutine in which a variable is set to a particular value. Is that value available everywhere else in the rest of the program? Thanks. playfullscientist
_________________
I am a playful scientist
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Fri Apr 22, 2005 9:22 pm    Post subject: Reply with quote

Yes, the concept of local variables is very new to AutoHotkey. In any regular label (hotkey and hotstring definitions count), all variables are global. Only in functions is there a distinction between global and local variables. As an example, this function will not make its variable global by default:

Code:
assign()
msgbox,%variable%
return

assign()
{
   variable = Lorem Ipsum
   return
}


However, this label will:

Code:
gosub,assign
msgbox,%variable%
return

assign:
variable = Lorem Ipsum
return


You can learn more about this behavior by reading the Functions section in your help file.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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