Hypermind Posted April 27, 2011 Share Posted April 27, 2011 Hello, I'm new to autoit and i was wondering how to 'merge' variables. For instance (weird example I know): $xpos = 5 $ypos = 2 $cell+$xpos+_+$ypos = "message" MsgBox(0, "title", $cell5_2) In php one can do it like this (combining $a and $i):${a.$i} Is this possible in autoit? Thanks in advance Link to comment Share on other sites More sharing options...
sahsanu Posted April 27, 2011 Share Posted April 27, 2011 (edited) In php one can do it like this (combining $a and $i):${a.$i} Do you mean $a="lorem" and $i="ipsum"... and after combining them you get $a="loremipsum"? $a="lorem" $i="ipsum" $a &= $i Msgbox(0,"","Variable $a is: " & $a) Take a look to Language Operators Edited April 27, 2011 by sahsanu Link to comment Share on other sites More sharing options...
iamtheky Posted April 27, 2011 Share Posted April 27, 2011 all apologies if i misunderstood, but in case you wanted to assign multiple variables to something else entirely... $xpos = 5 $ypos = 2 IF Assign("cell" & $xpos & "_"& $ypos , "message" , 2) Then MsgBox(0, "title", eval("cell" & $xpos & "_"& $ypos)) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Hypermind Posted April 27, 2011 Author Share Posted April 27, 2011 (edited) @sahsanu No I'm sorry that is not what I mean. It's difficult for me to explain.. I found a solution on php.net (for php) but it shows a solution for my problem. Maybe this will clear things upTo generate a family of variables, such as $a1, $a2, $a3, etc., one can use "variable variables" as follows: <?php for ($i = 1; $i <= 5; $i++) { ${a.$i} = "value"; } echo "$a1, $a2, $a3, $a4, $a5"; //Output is value, value, value, value, value ?> Note that the correct syntax is ${a.$i} rather than the perhaps more intuitive $a{$i} The dot (.) is the string concatenation operator. A family of variables might be used as an alternative to arrays. So I want to do that with AutoIt, however, this is really all that I need to know: ${a.$i} = "value" but then ofcourse in AutoIt language if that's possible. @iamtheky Hmm maybe that will work.. im a newbie so im really bad with autoIt and i don't understand your code completely but i will take a look at it, thanks for your reply. Edited April 27, 2011 by Hypermind Link to comment Share on other sites More sharing options...
sahsanu Posted April 27, 2011 Share Posted April 27, 2011 @sahsanu No I'm sorry that is not what I mean. Ah apologies, then iamtheky gave to you the right info. Another example: For $i=1 To 5 Assign("a" & $i, $i) Next MsgBox(0,"",Eval("a1") & Eval("a2") & Eval("a3") & Eval("a4") & Eval("a5")) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now