Jump to content
Sign in to follow this  
Parrot

Understanding Arrays

Recommended Posts

Parrot

It seems strange, but the instructions given in the help files for how to use arrays don't work. I try putting the following into a script:

$Array[0]="A"

And it gives me the following error message:

Expected a "=" operator in assignment statement.:

What's going on here?

Share this post


Link to post
Share on other sites
cppman

I don't think that was meant to be taken literally.

; "Dim" an array with 1 element - the "A".
Dim $Array[1] = ["A"]

$value = $Array[0] ; $value now equals "A"

Share this post


Link to post
Share on other sites
Parrot

I don't think that was meant to be taken literally.

I'm not sure I understand, how was it meant to be taken??

; "Dim" an array with 1 element - the "A".
Dim $Array[1] = ["A"]

$value = $Array[0] ; $value now equals "A"

Okay, that code works. Now I'm wondering where exactly it explains how to do this in the help files. Could you direct me to the proper location?

Share this post


Link to post
Share on other sites
Szhlopp

I'm not sure I understand, how was it meant to be taken??

Okay, that code works. Now I'm wondering where exactly it explains how to do this in the help files. Could you direct me to the proper location?

Your code "Array[0] = "a"" works if you declare it first.

Example:

Global $myarray1[5] ; Declare an array from 0 to 4
$myarray1[0] = "A"
MsgBox(0, "", $myarray1[0])
$myarray1 = "" ; Delete the array

Global $myarray2[5] = [0,1,2,5,10] ; Declare an array, and set the values

MsgBox(0, "", $myarray2[4])

Share this post


Link to post
Share on other sites
cppman

I'm not sure I understand, how was it meant to be taken??

Okay, that code works. Now I'm wondering where exactly it explains how to do this in the help files. Could you direct me to the proper location?

What I meant was, it was just an example. For example, if I show you this code:

someFunction(...)

Obviously, you wouldn't use that code directly.

To be honest, I think the help file does a poor job of explaining arrays (unless I'm just unable to find it in the help file).

Share this post


Link to post
Share on other sites
Parrot

What I meant was, it was just an example. For example, if I show you this code:

someFunction(...)

Obviously, you wouldn't use that code directly.

You mean pseudo code. That doesn't seem to be the case though. I have yet to see an example of pseudo code in the help file. And Szhlopp has demonstrated that the code works, but it needs to be declared first. I'm not sure why they didn't mention that in the help file.

To be honest, I think the help file does a poor job of explaining arrays (unless I'm just unable to find it in the help file).

The help file does seem to have a few shortcomings. Perhaps the community here should be asking for a better one, or perhaps banding together to create a more comprehensive document.

Where did you learn the ins and outs of arrays in AutoIt, BTW? Are there alternative help documents available or did you have to learn from people who already knew the system?

Share this post


Link to post
Share on other sites
Malkey

Where did you learn the ins and outs of arrays in AutoIt, BTW? Are there alternative help documents available or did you have to learn from people who already knew the system?

At the top right corner of the AutoIt forum pages you should see Wiki

Wiki - Tutorials - Tutorial_Core_Language - Arrays Tutorial.(a link less than half way down the scrolled page)

or the direct address

http://www.autoitscript.com/wiki/Arrays

Another forum example of array use at

http://www.autoitscript.com/forum/index.ph...st&p=518808

Edited by Malkey

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.