Jump to content

array help


Recommended Posts

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

Link to comment
Share on other sites

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