Switch Range Expressions

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
lmstearn
Posts: 688
Joined: 11 Aug 2016, 02:32
Contact:

Switch Range Expressions

Post by lmstearn » 02 Dec 2021, 13:37

[Moderator's note: Topic moved from Bug Reports.]

Works with deprecated If function:

Code: Select all

value := 2
	Switch (Value)
	{
		case IfGreater, 1 , Value:
		msgbox % Value
		Default:
	}
Doesn't work with brackets:

Code: Select all

value := 2
	Switch (Value)
	{
		case (IfGreater, 1 , Value):
		msgbox % Value
		Default:
	}
Neither with comparison operator (same without brackets):

Code: Select all

value := 2
	Switch (Value)
	{
		case (Value > 2):
		msgbox % Value
		Default:
	}
Thanks.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

User avatar
Xtra
Posts: 2744
Joined: 02 Oct 2015, 12:15

Re: Switch Range Expressions

Post by Xtra » 02 Dec 2021, 15:04

Its not doing what you think it is:

Code: Select all

value := 2
	Switch (Value)
	{
		case IfGreater, 3 , Value:
		msgbox % Value
		Default:
	}
Each case may list up to 20 values. Each value must be an expression, but can be a simple one such as a literal number, quoted string or variable. Case and Default must be terminated with a colon :.

User avatar
lmstearn
Posts: 688
Joined: 11 Aug 2016, 02:32
Contact:

Re: Switch Range Expressions

Post by lmstearn » 02 Dec 2021, 23:44

value := 2

Code: Select all

	Switch (Value)
	{
		case % "@xtra_is_right" := IfGreater, ComObjType(ComNonsense*),  +Value Noob_for_not_noticing_this:
		msgbox % Value
		Default:
	}
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

Post Reply

Return to “Ask for Help (v1)”