v1.1.36.00 - switch Critical Error? or code error?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
list
Posts: 221
Joined: 26 Mar 2014, 14:03
Contact:

v1.1.36.00 - switch Critical Error? or code error?

Post by list » 01 Dec 2022, 12:30

Edit: fixed by AutoHotkey 1.1.36.01

Perhaps not related to the changes in Switch and no doubt crappy code but:

I've isolated this to the code snippet below.
Before v1.1.36.00 this worked and didn't give an error and the code worked.
(in as far as I could test it - and it does what I need it to)

I can "fix it" by
1. Inserting a MsgBox
2. Quoting the "case" value so Case "1": works, Case 1: does not

Code: Select all

MsgBox % SetIcon("","",3,5) ; generates error

SetIcon(text,script,ShortCutSearchGui,ShortCutSearchGuiCounter)
	{
	 ; MsgBox % ShortCutSearchGui ; uncomment msgbox and there is no Critical Error
	 If (script = "")
		{
		 IconVal := "Icon1"
		 If RegExMatch(text[1] text[2],"i)\[\[html|md\]\]")
			IconVal:="Icon3"
		 If RegExMatch(text[1] text[2],"i)\[\[rtf\=")
			IconVal:="Icon4"
		 If RegExMatch(text[1] text[2],"i)\[\[image\=")
			IconVal:="Icon5"
		}
	 else
		{
		 IconVal := "Icon2"
		 If RegExMatch(text[1] text[2],"i)\[\[html|md\]\]")
			IconVal:="Icon6"
		 If RegExMatch(text[1] text[2],"i)\[\[rtf\=")
			IconVal:="Icon7"
		 If RegExMatch(text[1] text[2],"i)\[\[image\=")
			IconVal:="Icon8"
		}
	 if (ShortCutSearchGui = 1)
		Return IconVal

	 If (IconVal = "Icon1") ; texticon
		{
		 Switch ShortCutSearchGuiCounter
			{
			 default: IconVal:="Icon1"
			 Case  1: IconVal:="Icon9"
			 ;Case  "1": IconVal:="Icon9" ; quoting prevents error
			}
		}

	 Return IconVal
	}
Critical Error: Invalid memory read/write.

Line#
023: if RegExMatch(text[1] text[2],"i)\[\[image\=")
024: IconVal := "Icon8"
025: }
026: if (ShortCutSearchGui = 1)
027: Return,IconVal
029: if (IconVal = "Icon1")
030: {
---> 031: Switch ShortCutSearchGuiCounter
032: {
033: Default:
033: IconVal := "Icon1"
034: Case 1:
034: IconVal := "Icon9"
035: Case 2:
035: IconVal := "Icon10"

The program is now unstable and will exit.
Last edited by list on 02 Dec 2022, 07:59, edited 1 time in total.

User avatar
JoeWinograd
Posts: 2182
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: v1.1.36.00 - switch Critical Error? or code error?

Post by JoeWinograd » 01 Dec 2022, 13:36

Hi @list,

I filed a bug report here:

viewtopic.php?f=14&t=111067

Regards, Joe

teadrinker
Posts: 4309
Joined: 29 Mar 2015, 09:41
Contact:

Re: v1.1.36.00 - switch Critical Error? or code error?

Post by teadrinker » 01 Dec 2022, 13:44

JoeWinograd wrote:

Code: Select all

Case Default: Msg:="default"
Incorrect syntax, must be

Code: Select all

Default: Msg:="default"

User avatar
JoeWinograd
Posts: 2182
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: v1.1.36.00 - switch Critical Error? or code error?

Post by JoeWinograd » 01 Dec 2022, 14:10

Hi teadrinker,
Thanks for the correction! Regards, Joe

list
Posts: 221
Joined: 26 Mar 2014, 14:03
Contact:

Re: v1.1.36.00 - switch Critical Error? or code error?

Post by list » 01 Dec 2022, 14:44

Thx - if you quote the 1 it works in your example too
Case "1": Msg:="fails in 1.1.36 - works in 1.1.35"

User avatar
JoeWinograd
Posts: 2182
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: v1.1.36.00 - switch Critical Error? or code error?

Post by JoeWinograd » 01 Dec 2022, 14:51

Yes, I understood that from your initial post and had tested it with quotes.

Post Reply

Return to “Ask for Help (v1)”