case command?

Get help with using AutoHotkey and its commands and hotkeys
aaffe
Posts: 144
Joined: 16 Jan 2014, 04:23

case command?

16 Aug 2018, 08:19

One Question, perhaps I have forgotten About the possibility to do this:
Do we alreade have an case-command in ahk?
Like:

Code: [Select all] [Download] GeSHi © Codebox Plus

case a in
1) do xyz
2) do zzz
Default) do Nothing
end case
JoeWinograd
Posts: 1048
Joined: 10 Feb 2014, 20:00

Re: case command?

16 Aug 2018, 10:52

Hi aaffe,
There is no Case statement in AHK. You can simulate one with a series of If-Else statements. For example:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Regards, Joe
User avatar
gregster
Posts: 1382
Joined: 30 Sep 2013, 06:48

Re: case command?

16 Aug 2018, 12:33

Note that else if-statements don't have to be split into two separate lines. You can also do:

But there needs to be a space between else and if
JoeWinograd
Posts: 1048
Joined: 10 Feb 2014, 20:00

Re: case command?

16 Aug 2018, 13:04

Yep, that works, too, although I prefer the If statement on a separate line for readability. But, of course, that's a matter of coding style...both work...pick whatever you prefer. Thanks for pointing that out, gregster. Regards, Joe
aaffe
Posts: 144
Joined: 16 Jan 2014, 04:23

Re: case command?

17 Aug 2018, 01:18

Thank you. I know the Workaround with IFs, but I think a real case command would be better. But there isnt one as you wrote. Thanks for your answers!

Return to “Ask For Help”

Who is online

Users browsing this forum: ethangolson and 23 guests