Jump to content
Sign in to follow this  
Cap0

array help

Recommended Posts

Cap0

Dim $arr[4]
For $i = 0 to 3 - 1
$arr[$i] = int(random(0,10))
Next

what i want to do is get the values and display as strings:

example:

msgbox(0,'',$arr[0] & $arr[1] & $arr[2])

how would i do it in a for next loop without writing $arr[0-2]?

so the output would be, say 123($arr[0] = 1, $arr[1] = 2, $arr[2] = 3).

Share this post


Link to post
Share on other sites
randallc

Hi,

Here's 2 ways;

;ex01.au3
;ex01.au3
#include<array.au3>
Dim $arr[4], $msg
For $i = 0 To UBound($arr) - 1
    $arr[$i] = Int(Random(0, 10))
    $msg &= "$arr[" & $i & "]=" & $arr[$i] & ","
Next

MsgBox(0, "", $msg)

_ArrayDisplay($arr, "$arr elements")
Randall Edited by randallc

Share this post


Link to post
Share on other sites
Cap0

Thanks, works great :)

Edited by Cap0

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  

×