Global Var to Local Var?

Ask gaming related questions (AHK v1.1 and older)
Space_Ninja89
Posts: 6
Joined: 29 May 2018, 05:04

Global Var to Local Var?

06 Jun 2018, 09:50

Hey

The title says it all. The script by itself works but i could like to turn the toggle2 and toggle3 into a local var toggle so i can re use it.

Code: Select all

~*!2::
toggle2 := !toggle2
loop {
  if (toggle2 = False)
  break
  if (toggle2 = True)
  SendInput, {2}
  Sleep, 2000
  }               
return

~*!3::
toggle3 := !toggle3
loop {
  if (toggle3 = False)
  break
  if (toggle3 = True)
  SendInput, {3}
  Sleep, 2000
  }               
return
Is it possible?
Thank you for reading
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Global Var to Local Var?

06 Jun 2018, 09:56

Local to what? Local vars only exist for functions/methods. If you want to make it a function, they would still need to be separated variables, unless you made 2 functions, but then that's poor, redundant code.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 62 guests