Quantcast
Channel: AutoHotkey Community
Viewing all articles
Browse latest Browse all 579

Ask for Help (v2) • Trouble creating a switch

$
0
0

CODE:

switch := 1
MsgBox(switch) ;outputting current switch status at launch

F23::output()
F24::switch()

switch()
{
if switch = 0
{
switch := 1 ;if switch is off, turn it on
}
}

output()
{
if switch = 1
{
MsgBox("Yellow") if switch is on, output Yellow
switch := 0 ;reset switch back to off
}
else
{
MsgBox("Blue") ;switch is off, output Blue
}
}


when i run the switch function, i get this error
Error: This variable has not been assigned a value.

Specifically: local mySwitch (same name as a global)

010: }
015: {
▶016: If mySwitch == 0
017: {
018: mySwitch := 1


basically, i have a button, and based on another button i want it to change what it does

example: button is called color. when you press it, it'll always output Blue.
when i press my switch button, i want that color button to output Yellow, and then reset the switch so that it will output Blue again. make any sense?

Statistics: Posted by daqbancrackr — Today, 16:37



Viewing all articles
Browse latest Browse all 579

Trending Articles