Sign in to follow this  
Followers 0
Steveiwonder

Creating variable without knowing what it will be called?

6 posts in this topic

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

Share this post


Link to post
Share on other sites



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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 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!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0