Steveiwonder Posted March 22, 2010 Share Posted March 22, 2010 Hey All, Is it possible to create a variable from user input or by adding two names together. Something like this... $userinput = 5 For $i = 0 to $userinput Step +1 Local $var&$i; Next What im trying to get is 5 variables from the above code names like $var1 $var2 $var3 $var4 $var5 Not sure if its possible with autoit. I have searched the forum but not finding any result. Thanks Steve They call me MrRegExpMan Link to comment Share on other sites More sharing options...
Fulano Posted March 22, 2010 Share Posted March 22, 2010 Less of a solution, more of a sidestep: this looks to be a perfect spot to use an array. Local $userinput = 5 Local $var[$userinput] Would give you $var[0] to $var[4] #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
Steveiwonder Posted March 22, 2010 Author Share Posted March 22, 2010 Less of a solution, more of a sidestep: this looks to be a perfect spot to use an array. Local $userinput = 5 Local $var[$userinput] Would give you $var[0] to $var[4] Good idea but i forget to mention each of the 5 vars will be arrays so really it will be like this. $userinput = 5 For $i = 0 to $userinput Step +1 Local $var&$i[94] Next They call me MrRegExpMan Link to comment Share on other sites More sharing options...
Fulano Posted March 22, 2010 Share Posted March 22, 2010 (edited) Not a really big deal:Local $userinput = 5 Local $var[$userinput][94] Would give you $var[0] to $var[4], where each one is an array of 94 elements Edited March 22, 2010 by Fulano #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! Link to comment Share on other sites More sharing options...
Steveiwonder Posted March 22, 2010 Author Share Posted March 22, 2010 Aye, didn't really want to use it but ye. But is it even possible to combine the two array names as orignally posted? They call me MrRegExpMan Link to comment Share on other sites More sharing options...
Fulano Posted March 22, 2010 Share Posted March 22, 2010 (edited) Sort of, Assign(), IsDeclared() and Eval() can be used to Create, Check and Read custom variables from strings, but it should be noted that it is a rather awkward way of doing things. Also, it cannot be used to create/read arrays (or at least the documentation seems to indicate this). Also 2, it's probably going to be significantly slower than an array lookup. Edited March 22, 2010 by Fulano #fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja! 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