1

People use toggles as simple as

alt := not alt
if(alt)  {...}
else     {...}

I implement it as

F1::
    alt := not alt
    if(alt)   ...
Return

When F1 is clicked, popup message shows:

Warning: This variable has not been assigned a value.

Specifically: atl (a global variable)

---> 104: alt := not alt

I follow the example in #warn, to add two lines before the alt line. The same error still shows.

F1::
    #Warn
    ;alt := ""
    alt := not alt
    if(alt)
    {
    Click down
    }
    else
    {
    Click up
    }
Return

I have also tried to define alt outside of F1::, the same error still shows.

What should I do? Is there any short fully working example using such toggles?

Community
  • 1
  • 1
Ksthawma
  • 1,257
  • 1
  • 16
  • 28

2 Answers2

1

This gives error

...
...
return

Alt := 0
F1::
    alt := not alt
    if(alt) { ..}
Return

This is ok

Alt := 0
F1::
    alt := not alt
    if(alt) { ..}
Return

Alt := 0 is needed.

Ksthawma
  • 1,257
  • 1
  • 16
  • 28
0

Warn is not always great, remove it unless you really need it

I did not test your code but it looks okay, is that is all of it?

Alt := 0

F1::
Alt := !Alt
;more
Return

Hope it helps

blackholyman
  • 1,440
  • 1
  • 10
  • 14
  • I tried: 1) Alt := 0 is needed 2) when a `return` before `F1::` { [exists](https://gist.github.com/anonymous/158da18d91bc9ee15830) }, the script can still detect F1, but gives the said error. I commented the `return`, and everything is fine. – Ksthawma Dec 24 '14 at 13:47