Jump to content
Sign in to follow this  
t0ddie

this code $%^& (listing items in an array)

Recommended Posts

t0ddie

i have an array, and i want to show each variable in the array in a message box.

but i really dont think this is the best way to do this,

dim $var[10]
$var[0] = hi
$var[1] = hello
$var[2] = hey
$var[3] = howdy
$var[4] = hiya
$var[5] = yo
$var[6] = greetings
$var[7] = sup
$var[8] = dude
$var[9] = nice
msgbox(0,"test",$var[0] & " " & $var[1] & " " & $var[2] & " " & $var[3] & " " &_
$var[4] & " " & $var[5] & " " & $var[6] & " " & $var[7] & " " & $var[8] & " " &_
$var[9])

is there a command, or a way to display every variable in an array without listing each of them in the code like i have shown above?


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites
blindwig

i have an array, and i want to show each variable in the array in a message box.

...

is there a command, or a way to display every variable in an array without listing each of them in the code like i have shown above?

<{POST_SNAPBACK}>

See my _Array1Box() function:

http://www.autoitscript.com/forum/index.php?showtopic=12720

It's an improvement on the _ArrayDisplay() function - it can display up to 4095 items of an array and can display 2d arrays as well.

Share this post


Link to post
Share on other sites
scriptkitty

many ways to do it...

$var=stringsplit("hi|hello|hey|howdy|hiya|yo|greetings|sup|dude|nice","|")
$out=""
for $i=1 to $var[0]
$out=$out & $var[$i] & " "
next
msgbox(0,"test",$out)

; random greeting...
$ran=random(1,$var[0]+1)
msgbox(1,"greeting is",$var[$ran])

AutoIt3, the MACGYVER Pocket Knife for computers.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.