Warning: This variable appears to never be assigned a value.

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Bathinda
Posts: 15
Joined: 01 Jan 2023, 05:29
Contact:

Warning: This variable appears to never be assigned a value.

05 Apr 2023, 01:42

I'm getting above stated error in Line when running this simple script in Ahk v2.x:

Code: Select all

Run 'L:\Bagg\AHScripts\Win+n ScIte- 3.ahk'
MsgBox("", "", 3)
	(LTrim("Should I run startup apps?")
	)
	if (msgResult == 'Yes')
{
	MsgBox("gddd")
	}
User avatar
boiler
Posts: 17242
Joined: 21 Dec 2014, 02:44

Re: Warning: This variable appears to never be assigned a value.

05 Apr 2023, 02:15

Where did you come up with msgResult and why do you expect it should know what that is? You can’t make up syntax. It looks like something ChatGPT would come up with. That’s not how the result of the MsgBox is retrieved. It is the return value of the function call.

And then you are sticking a continuation line after the end of the MsgBox function call. It can’t jump into the parameter you’ve already defined as blank above it.

It looks like this is what you’re attempting to do:

Code: Select all

Run 'L:\Bagg\AHScripts\Win+n ScIte- 3.ahk'
if MsgBox("Should I run startup apps?", "", 3) = "Yes"
	MsgBox("gddd")

Or this:

Code: Select all

Run 'L:\Bagg\AHScripts\Win+n ScIte- 3.ahk'
msgResult := MsgBox("Should I run startup apps?", "", 3)
if (msgResult = "Yes")
	MsgBox("gddd")
Bathinda
Posts: 15
Joined: 01 Jan 2023, 05:29
Contact:

Re: Warning: This variable appears to never be assigned a value.

05 Apr 2023, 02:44

Thank you. And aplogies.
My mistake that I forgot to mention that I was a very beginner and was using ahk v1 at basic level, and got the (may be somewhat modified to fit to v2.x) code from ahk v1.x.

In the mean time, I tried harder in v2 help documents on ahk website (very well written). And I understood 90% of the problem. And when I came back to delete my question on these boards, it was already answered by you. And now I'm 100% clear. Sorry that I forgot to mention that I'm a very beginner.
User avatar
boiler
Posts: 17242
Joined: 21 Dec 2014, 02:44

Re: Warning: This variable appears to never be assigned a value.

05 Apr 2023, 02:47

No problem. It’s fine to ask questions as a beginner. Just have the documentation guide your syntax.
Bathinda
Posts: 15
Joined: 01 Jan 2023, 05:29
Contact:

Re: Warning: This variable appears to never be assigned a value.

05 Apr 2023, 03:02

I'm sorry that I forgot to mention that I'm very much a beginner and had gotten this code from my v1 script created by me. I had tried it to modify it v2.x specs, but couldn't succeed (even with the help of ahk1 to 2 converter).

After writing here, I tried harder on Ahk Help documents, and had understood the problem 90%. I came here to delete my question, and found your answer. Thank you for clearing.
Finally got this script with the help documents, which is working 100% ok. (Don't pay attention to any non-relevant changes):

Code: Select all

Run 'L:\Bagg\AHScripts\Win+n ScIte- 3.ahk'
result := MsgBox("Should I run (3) startup apps?","dialogue title", "YesNoCancel")
	if (Result = "Yes")
	MsgBox "gddd"

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Descolada, docterry, Draken, Rohwedder, vmech and 25 guests