Sign in to follow this  
Followers 0
mooboo

Adding To Variables

4 posts in this topic

How do i add numbers to variables...

something like...

$var = 0

$var + 1 = $var ;overwrite the variable with a new number

IS THIS POSSIBLE????

Share this post


Link to post
Share on other sites



$var = 0

$var = 1 + 0

you have to put the varible first then the equasion...

$var = 2 * 2

etc......... and yes you also can add varibles together if they both are numbers...


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

You almost had it the first time.

$var = 0
$var  = $var + 1;overwrite the variable with a new number one higher

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'll add my 2 cents:

$var = 0 is an example of an assignment statement.

In (almost) all programming languages, a single variable must appear on the left side of the equal sign. The right hand side can contain variables or literal strings/numbers.

0 = $var IS INVALID because the left-hand side is not a variable.

$var + 1 = $var is invalid for a simlar reason.

$var = $var is fine, although not very useful. :whistle: [Technical note: $var is being used two diffrent ways in this example. The left $var (L-value) is a variable being assigned to; the right $var (R-value) is a variable being read. Or something like that--I'm a little rusty on all the technical stuff....]

$foo = $bar ;This means take the value stored in $bar and assign it to a variable named $foo.

Hope that helps

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

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