Sign in to follow this  
Followers 0
stderr

Creation of an array not working?

6 posts in this topic

Is it my stupidity or is there something wrong with AutoIt?

$shops[0] = "720, 540"
$shops[1] = "500, 480"
$shops[2] = "500, 420"

for $pos IN $shops

    msgbox(0,"", $pos)

next

Becomes:

C:\Users\stderr\Desktop\autoit\test3.au3 - 0 error(s), 1 warning(s)
->23:13:13 AU3Check ended.rc:1
>Running:(3.3.6.1):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\stderr\Desktop\autoit\test3.au3"    
C:\Users\stderr\Desktop\autoit\test3.au3 (1) : ==> Expected a "=" operator in assignment statement.:
$shops[0] = "720, 540"
$shops^ ERROR
->23:13:14 AutoIT3.exe ended.rc:1
>Exit code: 1    Time: 1.366

Using AutoIt 3.3.6.1 on Windows 7 64bit (Ultimate)

greetings,

stderr

Share this post


Link to post
Share on other sites



Add something like Local $shops[3] at top of the script.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Add this at the beginning of the script

Local $shops[3];

Edit: You won this time trance... but next time! ;)

Edited by Calistoga

Share this post


Link to post
Share on other sites

Ok .. thanks for the hint.

Maybe it should be added in the Docs ... there is nothing to read about previous defining of an array.

Share this post


Link to post
Share on other sites

Ok .. thanks for the hint.

Maybe it should be added in the Docs ... there is nothing to read about previous defining of an array.

it is:

Arrays

An Array is a variable containing series of data elements of the same type and size. Each element in this variable can be accessed by an index number.

An example:

Let's say you want to store these series of characters: "A", "U", "T", "O", "I", "T" and "3".

You could use seven separate variables to do so, but using an Array is more efficient:

$Array[0]="A"

$Array[1]="U"

..etc..

$Array[6]="3"

To access a specific value in an Array, you only have to know the index number:

$MyChar=$Array[2]

This results in $MyChar containing the letter "T" (See also: 'operators').

The index number can also be substituted by another variable or an expression, so you can build complex ways to assign or access elements in an array.

Arrays can also be multi dimensional, when you use multiple series of index numbers, like:

$Array[0][0]="Upper-Left"

$Array[1][0]="Lower-Left"

$Array[0][1]="Upper-Right"

$Array[1][1]="Lower-Right"

(These values are just examples)

You can use up to 64 dimensions in an Array. The total number of entries cannot be greater than 2^24 (16 777 216).

Before you can start using Arrays in your script, you must define their bounds using the 'Dim' keyword.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Ok ... then i have overlocked this passage. :)

Have see the samples where nowhere a line with defining.

My fault!

Have still a nice day ;)

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  
Followers 0