Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Case Select


  • Please log in to reply
7 replies to this topic
royscott
  • Members
  • 27 posts
  • Last active: Nov 01 2009 01:01 PM
  • Joined: 22 Nov 2004
I would like to see a Case Select equivelant added to AutoHotKey. With this it would be easy to implement all sorts of handlers without having to use the If/Else ladder.

Nemroth
  • Members
  • 278 posts
  • Last active: Dec 31 2011 10:53 PM
  • Joined: 07 Sep 2004
in Planned Features, you will see

A simple select/switch/case structure as an alternative to a series of ""else if"" statements. This might also help with the lack of support for the OR conjunction

I'm totaly agree with you as I asked for it...

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Thanks, I've raised its priority.

Nemroth
  • Members
  • 278 posts
  • Last active: Dec 31 2011 10:53 PM
  • Joined: 07 Sep 2004
Chris, thanks for this ... elevation :D :D :D

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
For those of us not familiar with conventional programming, (AHK my first) how exactly would that work? I.e., what syntax?

exhueydriver
  • Members
  • 51 posts
  • Last active: Sep 07 2005 07:07 PM
  • Joined: 12 Jul 2004
To borrow from your example

If var1 = yes, Do this1
{
If var2 = yes, Do this2
{
If var3 = yes, Do this3,
Else
{
**Code to be executed**
}
}
}
Return

In a CASE Statement, it would be

Case
{
var1 = yes, Do this1,
var2 = yes, Do this2,
var3 = yes, Do this3,
Code to be executed
}

Return

( Each statement has an "If, Do this" clause, but it's much cleaner, and
it doesn't need an Else statement. IOW, in the above, you could eliminate the " code to be executed" statement if you didn't need it)
Thanks
Don

I borrowed this from another post you had done, Re: "And" Function,
since posting this, I realized that to do the same "AND" with a Case function would require the "AND" Function. Hope we can get both it and the
"OR" Function

(the above is not tested, and is presented for educational purposes only)
lol

BoBo
  • Guests
  • Last active:
  • Joined: --

and is presented for educational purposes only


Eh, would you mind to educate/advise as well to use that funny "Code" option/feature for better visualization of your code ?
It keeps the code separate from the rest of the story (and btw, would make even more sense if you'd indent some of your code sections).

Thx for listening :wink:

8)

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

I realized that to do the same "AND" with a Case function would require the "AND" Function. Hope we can get both it and the "OR" Function

Thanks for the details and example.