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 

Can you output a virtual vars's value using 2 variables?

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



Joined: 28 Nov 2007
Posts: 17
Location: Missouri, USA

PostPosted: Wed Nov 28, 2007 1:15 am    Post subject: Can you output a virtual vars's value using 2 variables? Reply with quote

I started messing with autohotkey about 3 days ago and i'm learning better ways to do things constantly. I love this program. Learning has kept me busy continually revising my script and tidying it up. I've just started implementing a loop/variable process to cut down on the lines of code and can't seem to output a value reference a variable name which actually is stated using either 2 variables or a string and a variable.

This for example works fine:

tempvar = 1
Loop 30
{
IniRead, websiteurlvarout%tempvar%, configdata.ini, website, websiteurl%tempvar%
tempvar++
}

I need to do something along these lines though:

tempvar = 2
Loop 14
{
Gui, 2:Add, Edit, R1 +w100 +vwebsitevarin%tempvar%, %websitevarout%%2% ;<------
tempvar++
}

or

tempvar = 2
Loop 14
{
Gui, 2:Add, Edit, R1 +w100 +vwebsitevarin%tempvar%, websitevarout%2% ;<------
tempvar++
}

This is not working obviously. In this case you'll see that "websitevarout" is constant. Is what i'm trying to do even possible? Is there a better way to do this? Please guide me!

Thx
Labouche
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Wed Nov 28, 2007 2:04 am    Post subject: Reply with quote

Use the code tag.

If you wish to assign a changing variable when adding controls in a loop to a gui:

Code:
Loop, 10
{
     Gui, 1: Add, Edit, x+10 y10 w50 vVariable%A_Index%, % VarContents%A_index%
}
Back to top
View user's profile Send private message
Labouche10



Joined: 28 Nov 2007
Posts: 17
Location: Missouri, USA

PostPosted: Wed Nov 28, 2007 2:24 am    Post subject: Reply with quote

SWEET! Thanks for the A_Index variable that is very useful. I read the section in the help file for that. I'm still confused about one thing and I feel stupid about this, when you said:

Gui, 1: Add, Edit, x+10 y10 w50 vVariable%A_Index%, % VarContents%A_index%

Can you give me some more direction on the "% VarContents%A_Index%" part? I'm sorry I just don't follow 100%

*damned noobs*

Thx
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Labouche10



Joined: 28 Nov 2007
Posts: 17
Location: Missouri, USA

PostPosted: Wed Nov 28, 2007 2:42 am    Post subject: Reply with quote

AHHHH I figured it out by doing some forum searching. Thanks for the help man!! For anyone else who reads this thread, I worked it out like this:

Gui, 2:Add, Edit, R1 +w100 +vwebsitevarin%A_Index%, % websitevarout%A_Index%

Where "websitevarout" is the string constant prefix for this group of variables.

Thanks again for the help!!
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Lexikos



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

PostPosted: Wed Nov 28, 2007 10:03 am    Post subject: Reply with quote

FYI, the "% " prefix on a parameter forces it to be evaluated as an expression. Double-dereferencing (accessing dynamically-named variables) can only be done with expressions (or Transform,..,Deref.)
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