1
votes

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?

2

2 Answers

1
votes

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.

0
votes

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