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 

How to add multiple variables together

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



Joined: 28 Apr 2007
Posts: 33

PostPosted: Fri Oct 03, 2008 9:30 pm    Post subject: How to add multiple variables together Reply with quote

I am sure that this is likely easy, but when searching the forum, I could not find any examples. I have a script that has 7 variables, lables var1, var2, etc. I need to add them together to make an 8th variable, but I can't figure out how to do it. Can anyone help me please?

Thanks!
Back to top
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 666
Location: MN, USA

PostPosted: Fri Oct 03, 2008 10:31 pm    Post subject: Reply with quote

Code:
Loop,7
 var8 += var%A_Index%

_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
Sephiroth2906



Joined: 28 Apr 2007
Posts: 33

PostPosted: Sun Oct 05, 2008 12:51 am    Post subject: Reply with quote

Huh, that is marvelous. I appreciate the help. I am curious, is there some kind of step by step tutorial that introduces the advanced capability of the program? I looked up A_Index, and the description made no sense whatsoever, at least not until I threw this into my script. The help file is great, but most of the time, I need to come to the forum to find the answers to my questions, because when I look up questions like this in the help file, I get no results, because I do not ask the right question. Most of the time, here in the forum, I get an answer, but I do not understand it, I see it working, but have no explanation as to why it works. Thanks again.
Back to top
View user's profile Send private message
PurloinedHeart



Joined: 04 Apr 2008
Posts: 209
Location: Canada

PostPosted: Sun Oct 05, 2008 6:55 pm    Post subject: Reply with quote

Maybe you should spend a bit more time looking at the description, you could also look at examples given in the manual.

eg. For the A_Index description it says
Quote:

This is the number of the current loop iteration (a 64-bit integer). For example, the first time the script executes the body of a loop, this variable will contain the number 1. See Loop for details.


If you look at Loops, it will say
Quote:

The built-in variable A_Index contains the number of the current loop iteration. For example, the first time the script executes the loop's body, this variable will contain the number 1. For the second time, it will contain 2, and so on. If an inner loop is enclosed by an outer loop, the inner loop takes precedence. The value will be 0 whenever the variable is referenced outside of a loop. This variable works inside all types of loops, including file-loops and registry-loops.

And if it's still not clear, there are some good examples such as
Code:

Loop, 3
{
    MsgBox, Iteration number is %A_Index%.  ; A_Index will be 1, 2, then 3
    Sleep, 100
}

Loop
{
    if a_index > 25
        break  ; Terminate the loop
    if a_index < 20
        continue ; Skip the below and start a new iteration
    MsgBox, a_index = %a_index% ; This will display only the numbers 20 through 25
}


And if you eevr get a reply in the forum that you do not understand, people usually won't mind explaning what they did
Back to top
View user's profile Send private message
Dra_Gon



Joined: 25 May 2007
Posts: 314

PostPosted: Sun Oct 05, 2008 8:31 pm    Post subject: Reply with quote

A good way {for me anyway} to figure out how these commands work is to get someone's script and tweak it in simple ways. Make small enough changes so that you can see what the script is doing in response to your changes. For each command in such a script you can go to the Help file and see what is allowed then make your own tweak. Eventually you'll get to know what you can/can't do.

Ciao,
Dra'Gon
_________________

For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/
Back to top
View user's profile Send private message Send e-mail
jebbit



Joined: 06 Oct 2008
Posts: 3

PostPosted: Mon Oct 06, 2008 2:20 am    Post subject: Reply with quote

2 days new to this myself. I have found this command.

EnvAdd

It adds to an existing variable

EnvAdd, original_variable, Variable_to_add_to_it
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