Sign in to follow this  
Followers 0
t8inevergreen

The Mystery of -=

8 posts in this topic

So, we all know that operators like += and &= work in AutoIt...

But why does -= throw a syntax error?

Share this post


Link to post
Share on other sites



$a=5
$a-=2
MsgBox(0,"",$a) ;shows 3

No problems here.

Share this post


Link to post
Share on other sites

I don't see a problem. Try this test

$i = 1
MsgBox(0, "results", "$i = " & $i)
$i += 1
MsgBox(0, "results", "$i = " & $i)
$i -= 1
MsgBox(0, "results", "$i = " & $i)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Hmm, that does seem to work.

In my situation, I was doing this:

Global $ArrayMax -= $MultiList[0]-1

Where $ArrayMax and $MultiList[0] are guaranteed numbers.

Share this post


Link to post
Share on other sites

You can't add or subtract something that hasn't been assigned yet...

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

What do you get with this?

Global $ArrayMax -= $MultiList[0]-1
MsgBox(0, "Results", $ArrayMax)

Actually that line looks screwy. What were you expecting as a return? What is the size of the array?

EDIT: And what evilertoaster said

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Dump the global and see if it works. When you redeclare it, it might be wiping the value.

Share this post


Link to post
Share on other sites

Richard Robertson: THANKS! That made it work, and now that I look at it, the Global was unnecessary.

And to answer the questions of Evil Toaster and GEOSoft, that line was just an excerpt from a little algo that found duplicates or accidentally included files in a list of daily log files, the line where the syntax error was thrown.

-$ArrayMax was the Ubound value of the list array and the maximum for my For loop that compared each list item to the one below it after being sorted by the incredibly useful ArrayNatural UDF.

-$MultiList was the array of duplicates that was populated after a single duplicate was found and a While loop was run to find any further duplicates below.

Both values are dynamic, but both were declared beforehand and were guaranteed to be numbers.

Thanks for your help everyone!

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