Jump to content
Sign in to follow this  
Nialaghr

Array display

Recommended Posts

Nialaghr

Hi,

I have three arrays and I need to display the array corresponding to the name passed from cmdline.(A1,B1 or C1)

ex:

#include <array.au3>

$A1=_ArrayCreate("A1","A2","A3")

$B1=_ArrayCreate("B1","B2","B3")

$C1=_ArrayCreate("C1","C2","C3")

$Name="$"& $CmdLine[1]

MsgBox(0," Name",$Name)

$d1 =_ArrayDisplay($Name)

It looks like the variable $Name is not recognized as an Array.

Thanks

Share this post


Link to post
Share on other sites
weaponx

Switch $CmdLine[1]
Case "A1"
_ArrayDisplay($A1)

Case "B1"
 _ArrayDisplay($B1)

Case "C1"
 _ArrayDisplay($C1)
EndSwitch

Share this post


Link to post
Share on other sites
Nialaghr

Thanks for you answer eaponx,

but since the real program is much more complex it makes is difficult to use this solution. I am really looking for a way to use the parameter passed by CmdLine[]

Share this post


Link to post
Share on other sites
weaponx

#include <array.au3>

$cmd = "A1"

$A1=_ArrayCreate("A1","A2","A3")
$B1=_ArrayCreate("B1","B2","B3")
$C1=_ArrayCreate("C1","C2","C3")

$temp = Eval($cmd)


_ArrayDisplay($temp)

Share this post


Link to post
Share on other sites
Nialaghr

Thanks Weaponx,

exactly what I was looking for. Just learned a new command: Eval(). :)

works great!

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  

×