Jump to content

Alternative to Eval Array


 Share

Recommended Posts

I'm trying to store info in an array, and then use that info in a fuction that has been passed only a string matching the array's name.

Example:

Global $test_ab[10] = ["test_ab", "t", 2500, 0, 0, 0, 0, 110]

Function($variable)

$question = $variable[2]

EndFunc

----------------------------------------------------------------

When $variable = "test_ab" I'm hoping that $question will = "t". The only way I can think to make this work would be:

$question = Eval($variable & "[2]")

But Eval is not designed to work like that. Any ideas to work around this? Thanks ;)

Link to comment
Share on other sites

Another way to look at it:

Global $test_ab[10] = ["test_ab", "t", 2500, 0, 0, 0, 0, 110]
Global $sTest = "test_ab"

$aVar = Eval($sTest)
For $n = 0 To 2
    $RET = $aVar[$n]
    ConsoleWrite("$" & $sTest & "[" & $n & "] = " & $RET & @LF)
Next

Keeping in mind that Assign/Eval are the evil spawn of daemons.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...