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

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
Guest Ultima

Thanks, I like the StringSplit method.

Share this post


Link to post
Share on other sites

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...