Jump to content

$a[0] = $zero ;ERROR - ?! why


Guest autoit3
 Share

Recommended Posts

$a[0] = 0
$a^ ERROR

Error: Expected a "=" operator in assignment statement.

---

How do I assign a value to an element of the array $a?

My above attempt resulted in error.

Edit: Title should read "$a[0] = 0" instead of "$a[0] = $zero", question still stands.

Edited by autoit3
Link to comment
Share on other sites

;//Just A Example!
Dim $array[5], $zero

$array[0] = $zero
$array[1] = $one
$array[2] = $two
$array[3] = "Three";If you are setting a varible or a arry to hold text use quotes!

Thats all you need to do to set arrays to whatever you want!

OminousIdol

<{POST_SNAPBACK}>

Thank You!!

--

Some

$a[0] = 0
statements still geneate the error "Expected a "=" operator in assignment statement" -- any ideas? Edited by autoit3
Link to comment
Share on other sites

I think it's because you need more than just the $a[0], I think you also need at least $a[1] or another one.

<{POST_SNAPBACK}>

Global $a[2]
$a[0] = 0;fine
$a[0] = 0;error, "needs = operator"

Pretty sure it is a bug?

Update:

Apparently the more elements I declare in the $a array the more times it allows me to initilize the zeroith element. It seems to also randomly complain that $a[0] = 0 is missing a "=". Either this is a bug in the code or arrays are handeled irregularly in AutoIt.. ?

I need to be able to constantly reset $a[0] within a loop structure, for some reason I appear to be limited by the amount of elements I declare in the array. Help please!

Edited by autoit3
Link to comment
Share on other sites

What about this example?

Global $array[4], $zero = 2, $one = 5, $two = 10

$array[0] = $zero
$array[1] = $one
$array[2] = $two
$array[3] = "Three";If you are setting a varible or a arry to hold text use quotes!
MsgBox(0,'title' , 'This equals  ' & $array[3])

Does this help?

Link to comment
Share on other sites

Global $a[2]
$a[0] = 0;fine
$a[0] = 0;error, "needs = operator"

Pretty sure it is a bug?

Update:

Apparently the more elements I declare in the $a array the more times it allows me to initilize the zeroith element. It seems to also randomly complain that $a[0] = 0 is missing a "=". Either this is a bug in the code or arrays are handeled irregularly in AutoIt.. ?

I need to be able to constantly reset $a[0] within a loop structure, for some reason I appear to be limited by the amount of elements I declare in the array. Help please!

<{POST_SNAPBACK}>

Global $a[2]
$a[0] = 0
$a[0] = 0
$a[0] = 0
$a[0] = 0
$a[0] = 0
$a[0] = 0
For $I = 1 To 100
   $a[0] = 0
Next

MsgBox(0, '', $a[0])

that works fine here. maybe theres some other error in your script? a complete copy+paste would be helpful i think. (if it's not too big)

Greetings,

ZeD

Link to comment
Share on other sites

I deleted the script so it doesent matter anymore. Thanks for the help though.

<{POST_SNAPBACK}>

yet another sample:

Dim $a[5]

$a[0] = 0

$a[4] = " 5th element"

MsgBox(1, "", $a[0] & $a[4])

so, an array has to be DIM (dimensioned) for autoit3 to know how big it will be

(because it has to reserve a chunk of memory for the array)

my array $a[5] has 5 elements from $a[0] to a$[4]

DON'T try to use $a[5] it does not exist because the index starts at zero

I use MsgBox as my trusty print command for debugging purposes

Link to comment
Share on other sites

yet another sample:

Dim $a[5]

$a[0] = 0

$a[4] = " 5th element"

      MsgBox(1, "", $a[0] & $a[4])

so, an array has to be DIM (dimensioned)  for autoit3 to know how big it will be

(because it has to reserve a chunk of memory for the array)

my array $a[5]  has 5 elements from $a[0] to a$[4]

DON'T  try to use $a[5] it does not exist  because the index starts at zero

I use MsgBox as my trusty print command for debugging purposes

<{POST_SNAPBACK}>

I didn't think AutoIt reserved the memory space until you place a value in the memory slot?

*** Matt @ MPCS

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