#Warn error: unassigned variable, wrong location stated

Report problems with documented functionality
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

#Warn error: unassigned variable, wrong location stated

26 Mar 2019, 16:23

The issue relates to variables created via DllCall.

When I run this code in one of my scripts. #Warn correctly states the location (line number) of vType, but incorrectly states the location (file name, no line number given) of vSize (stating a file that does not even use 'vSize'). Tested on AHK v1.1.29.01 and v1.1.30.03.

Code: Select all

#Warn

;q:: ;test #Warn
hRootKey := 0x80000001 ;HKEY_CURRENT_USER := 0x80000001
vSubKey := "Software\Microsoft\Notepad"
vFlags := 0x1 ;KEY_QUERY_VALUE := 0x1
hKey := 0
vRet := DllCall("advapi32\RegOpenKeyEx", "Ptr",hRootKey, "Str",vSubKey, "UInt",0, "UInt",vFlags, "Ptr*",hKey)

vChars := 16383
VarSetCapacity(vValueName, vChars*2+2, 0)
;vType := vSize := 0
vIndex := 0
vRet := DllCall("advapi32\RegEnumValue", "Ptr",hKey, "UInt",vIndex, "Str",vValueName, "UInt*",vChars, "Ptr",0, "UInt*",vType, "Ptr",0, "UInt*",vSize)
return
I have not been able to isolate the problem, and so can't provide a stand-alone example. But here are the 2 error messages:

Code: Select all

---------------------------
AutoHotkey.ahk
---------------------------
Warning:  This variable has not been assigned a value.

Specifically: vType  (a global variable)

	Line#
	4708: vSubKey := "Software\Microsoft\Notepad"
	4709: vFlags := 0x1
	4710: hKey := 0
	4711: vRet := DllCall("advapi32\RegOpenKeyEx", "Ptr",hRootKey, "Str",vSubKey, "UInt",0, "UInt",vFlags, "Ptr*",hKey)
	4713: vChars := 16383
	4714: VarSetCapacity(vValueName, vChars*2+2, 0)
	4716: vIndex := 0
--->	4717: vRet := DllCall("advapi32\RegEnumValue", "Ptr",hKey, "UInt",vIndex, "Str",vValueName, "UInt*",vChars, "Ptr",0, "UInt*",vType, "Ptr",0, "UInt*",vSize)
	4718: Return
	4723: {
	4725: vSize := 0
	4726: }
	4727: Exit
	019: {
	020: Return

For more details, read the documentation for #Warn.
---------------------------
OK
---------------------------
---------------------------
AutoHotkey.ahk
---------------------------
Warning in #include file "C:\Users\##\Desktop\###\### folder\### ### - Internet.ahk":
     This variable has not been assigned a value.

Specifically: vSize  (a global variable)

	Line#
	3492: JEE_SplashText("warning: filename issue", 650)
	3493: Else
	3493: if !(JEE_CIDGetDir(hWnd) ~= "\\Pictures$")
	3494: JEE_SplashText("

" "warning folder not My Pictures

", 650)
	3495: Else
	3496: SendInput("{Enter}")
	3497: JEE_RetX()
	3506: ControlClick("Button1", "Save Webpage")
	3507: WinClose("A")
	3508: JEE_RetX()
	3523: if (A_TimeIdle > 200)
	3524: JEE_RetX()
	3526: hWnd := WinGetID("A")
	3527: vWinClass := WinGetClass("ahk_id " hWnd)

For more details, read the documentation for #Warn.
---------------------------
OK
---------------------------
Thanks for reading.

[EDIT:] If I assign vType a value, (then I don't get an error for vType and) I get an error message for vSize citing the correct location.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 49 guests