Jump to content

Accessing an Array element using Eval Function


Go to solution Solved by sahsanu,

Recommended Posts

I have an requirement to loop through multiple Arrays in a single loop[Arrays itself].

So just wondering if the following is possible (Actually when tested it prints nothing though there was no syntax error!

Global $MMEList[3] = ["LSMC1-MME0001-CST","LSMC1-MME0004-CST","LSMC1-MME0010-CST"]
Global $SGWList[3] = ["LSMC1-MME0001-CST","LSMC1-MME0004-CST","LSMC1-MME0010-CST"]
Global $NEType[2] = ["MME","SGW"]
For $i=0 To 2 
  ConsoleWrite(Eval($NEType[$i] & "List[" & $i &"]")) 
Next 
Exit

 

Link to comment
Share on other sites

  • Solution

You could try to use Execute instead of Eval:

Global $MMEList[3] = ["LSMC1-MME0001-CST", "LSMC1-MME0004-CST", "LSMC1-MME0010-CST"]
Global $SGWList[3] = ["LSMC1-MME0001-CST", "LSMC1-MME0004-CST", "LSMC1-MME0010-CST"]
Global $NEType[2] = ["MME", "SGW"]
For $i = 0 To 1
    ConsoleWrite("The content of " & "$" & $NEType[$i] & "List[" & $i & "] is: ")
    ConsoleWrite(Execute("$" & $NEType[$i] & "List[" & $i & "]") & @CRLF)
Next
Exit

Cheers,

sahsanu

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...