Sign in to follow this  
Followers 0
ViciouS

$var = $var + 1 problem

4 posts in this topic

noob question for sure.

$var = 0

$var = $var + 1

why is it that its creating 1111111111, instead of 1 2 3 4 5 6 7..... like i want it to?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

This:

$var = 0
$var = $var + 1
$var = $var + 1 ;; etc

Will NOT produce "11...etc". (not even if you used quoted value's) ... your probably using '&' instead of '+' in your real code.

Tip:

Show your real code instead of your interpretation of what you think your/the code is doing.

(apply's to all, just double, or even triple, for beginners ... or noob's if you like.)

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

The addition operation is not treated as string concatenation in the AutoIt language. Try these examples

$var = 1
$var = $var + 1
MsgBox(64, "Test 1", $var)

$var = "String"
$var = $var + 1
MsgBox(64, "Test 2", $var)

$var = "String"
$var = $var + "1"
MsgBox(64, "Test 3", $var)

If the addition operation is used with strings, then the statement is evaluated using the numerical representation of the expression contained in the string. To see/understand the numeric representation of several string expressions see the Number() function in the help file.

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