Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Auto Increment


  • Please log in to reply
4 replies to this topic
Jackson
  • Guests
  • Last active:
  • Joined: --
How do increment a variable???

I tried searching for increment... but didnt find anything.

Basically:

x = x + 1

but that didnt work....

None
  • Members
  • 3199 posts
  • Last active: Nov 05 2015 09:55 PM
  • Joined: 28 Nov 2009
options :)
x:=x+1

x+=1

x++


SifJar
  • Members
  • 176 posts
  • Last active: Mar 19 2012 03:57 PM
  • Joined: 13 Feb 2010

How do increment a variable???

I tried searching for increment... but didnt find anything.

Basically:

x = x + 1

but that didnt work....


It'd need to be x = %x% + 1, because with the = assignment operator, plain text is taken as a string, you have to enclose variables in %.

To use x + 1, you'd have to use := assignment operator, which takes plain text to be a variable and strings must be enclosed in quotation marks (").

With both, numbers are just typed normally.

MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
Here's what you should read carefully:
<!-- m -->http://www.autohotke...s/Variables.htm<!-- m -->

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


  • Guests
  • Last active:
  • Joined: --
when I did x = %x% + 1, x then had: 1 + 1 because i had set x to be 1 in the start

but when i did x++ it worked.

Thanks