"This dynamic variable is blank." errors

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
bmcclure
Posts: 31
Joined: 29 May 2018, 22:11
Location: West Virginia, USA
Contact:

"This dynamic variable is blank." errors

23 Apr 2021, 19:02

When upgrading my script's version of AHK v2-alpha, I started getting a number of errors that simply say "This dynamic variable is blank."

Unfortunately the errors don't provide any context such as what the dynamic variable name is, what file or line number the error is from, etc.

Does anyone know what change might have caused this to start showing up, or if there's an effective way of finding out more information to track down where it's coming from?
bmcclure
Posts: 31
Joined: 29 May 2018, 22:11
Location: West Virginia, USA
Contact:

Re: "This dynamic variable is blank." errors

23 Apr 2021, 19:07

I tracked this one down, I think.

I was calling a function dynamically like:

Code: Select all

func := this.map[a][b]
%func%(param)
But after reading the latest docs, it seems to work without the dynamic variable reference now:

Code: Select all

this.map[a][b](param)
Cool!
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: "This dynamic variable is blank." errors

24 Apr 2021, 23:45

The dynamic variable name is "", i.e. blank. ;)

At least, that's what the error message is supposed to mean. In this case I suppose the "name" was actually an object. It should be throwing a TypeError.

%func%() wasn't a dynamic variable reference before; it was a dynamic function call. The only variable being referenced was the non-dynamic variable func. Even if func contained a name, the target was a function, not a variable. In other words, %func% was name substitution. Now, %func% is still name substitution but the myfunc in myfunc() is actually a variable reference.

When you use %func%, you may think "the dynamic variable name" is "func". That isn't the case. "func" is the name of the non-dynamic variable which provides the name of the dynamic variable. However, the name is not required to be provided by a variable; it could be an expression such as a function call, or concatenation such as My%func% or %"My" func%.

I assume you've worked out that you don't actually want a dynamic variable, since what you have is a function object, not a variable name.

You say the errors didn't indicate what file or line number the error is from... that should be impossible, unless you're overriding the error handling and suppressing that information yourself. The standard error dialog always points at the line containing the expression which threw the error.
bmcclure
Posts: 31
Joined: 29 May 2018, 22:11
Location: West Virginia, USA
Contact:

Re: "This dynamic variable is blank." errors

25 Apr 2021, 11:36

Thanks for the clarification! That definitely helped improve my understanding (and realize my terminology mistake)

I didn't actually want a dynamic variable, I was using the wrong terminology. I wanted to call the function dynamically and was doing so based on the documentation at the time in a way that seemed to work fine--but after updating my AHK v2-alpha to a newer version, it took me a while to realize the difference in how to properly call the function dynamically.

Also, you're right about the error handler after looking more into it--my error handler was producing another error related to a syntax change from the AHK update, so somehow it ended up producing a simple dialog for the first error.

Thanks again!

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Albireo, niCode and 66 guests