Jump to content
Sign in to follow this  
Guest Ultima

how to declare array with pre-initialized values?

Recommended Posts

Guest Ultima

I want to declare an array with some pre-initialized values like

int Array[3] = {1, 2, 3}

Is there anyway to do it in AutoIt?

Share this post


Link to post
Share on other sites
therks

Nope.

Only thing you can do is something like with StringSplit...

$array = StringSplit('Value 1,Value 2,Value 3', ',')

Or something similar.

Share this post


Link to post
Share on other sites
SlimShady

The correct syntax in AutoIt:

Method 1.

Dim $Array[3]
$Array[0] = 1
$Array[1] = 2
$Array[2] = 3

Method 2.

Dim $Array[3]
For $i = 0 To 2
   $Array[$i] = $i + 1
Next

Edit:

Or as Saunders mentioned.

Method 3.

$Array = StringSplit("1,2,3", ",")
Edited by SlimShady

Share this post


Link to post
Share on other sites
Klaatu

Or use the included Array.au3 file function _ArrayCreate:

#include "Array.au3"

Dim $Array = _ArrayCreate(1, 2, 3)

My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!

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.