Sign in to follow this  
Followers 0
Shocker1322

Using a Variable Variable

2 posts in this topic

Is it possible to use a string contained within a variable as the variable name itself? For example:

CODE
Dim Array1[2]

Dim Array2[2]

Func Velocity($Name)

$Name = "$Array" & $Name

;Return velocity of array

EndFunc

Velocity(1)

Velocity(2)

In the function "Velocity" the string contained within $Name varies. Can the contents of $Name be used as the variable name, or perhaps there is another way to do this? This is just an example of what I am trying to do, the real thing is more complicated. Thank you.

Share this post


Link to post
Share on other sites



You can use Assign

Assign ( "varname", "data" [, flag] )

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

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