Sign in to follow this  
Followers 0
sivaramanm

Accessing an Array element using Eval Function

2 posts in this topic

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

 

Share this post


Link to post
Share on other sites



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

1 person likes this

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