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.
Case Select
Started by
royscott
, Dec 01 2004 03:52 PM
7 replies to this topic
#1
-
Posted 01 December 2004 - 03:52 PM
in Planned Features, you will see
I'm totaly agree with you as I asked for it...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
#2
-
Posted 01 December 2004 - 05:31 PM
For those of us not familiar with conventional programming, (AHK my first) how exactly would that work? I.e., what syntax?
#5
-
Posted 02 December 2004 - 09:57 PM
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
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
#6
-
Posted 03 December 2004 - 04:19 AM
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)
#7
-
Posted 03 December 2004 - 10:28 AM
Thanks for the details and example.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
#8
-
Posted 03 December 2004 - 02:36 PM