Code: Select all
if choice = left
f__move("left")
if choice = right
f__move("right")
if choice = up
f__move("up")
if choice = down
f__move("down")
Code: Select all
if choice = left
f__move("left")
if choice = right
f__move("right")
if choice = up
f__move("up")
if choice = down
f__move("down")
Code: Select all
if choice = left
f__move("left")
else if choice = right
f__move("right")
else if choice = up
f__move("up")
else if choice = down
f__move("down")
Code: Select all
if choice = left
f__move("left")
else if choice = right
f__different_function()
Code: Select all
if choice = left f__move("left")
if choice = right f__different_function()
Is it possible for choice to hold both left AND right?Terka wrote:my point is TO SHORTEN THE CODE
would like to have something like(else command is not necessary here)Code: Select all
if choice = left f__move("left") if choice = right f__different_function()
Code: Select all
if (choice = "left" || choice = "right") f__move(choice)
if (choice = "up" || choice = "down") f__different_function()
Code: Select all
if (choice = "left" || choice = "right") f__move(choice)
if (choice = "up" || choice = "down") f__different_function()
Code: Select all
q::
choice := "left"
;choice := ""
if (choice = "left" || choice = "right"
|| choice = "up" || choice = "down")
f__move(choice)
if (choice ~= "^(left|right|up|down)$") ;preferred
f__move(choice)
if RegExMatch(choice, "^(left|right|up|down)$")
f__move(choice)
if choice in left,right,up,down
f__move(choice)
return
w::
choice := "left"
;choice := ""
if (choice = "left" || choice = "right") f__move(choice)
MsgBox, % "_"
return
f__move(x)
{
MsgBox
}
Code: Select all
(choice = "left" || choice = "right") ? f__move(choice) : (choice = "up" || choice = "down") ? f__different_function(choice) : f__else(choice)
Code: Select all
for k, choice in ["left","right","up","down","out"]
(choice = "left" || choice = "right") ? f__move(choice) : (choice = "up" || choice = "down") ? f__different_function(choice) : f__else(choice)
f__move(a){
msgbox % A_ThisFunc "`n" a
}
f__different_function(a){
msgbox % A_ThisFunc "`n" a
}
f__else(a){
msgbox % A_ThisFunc "`n" a
}