wrong syntax - why? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

wrong syntax - why?

11 May 2021, 20:54

Code: Select all

Global SearchWindows:=object()
...
SearchWindows[A_Gui]:={Result: XResult}
...
x:=SearchWindows[A_Gui].Result
What is wrong with the last line? I get the error message:

Code: Select all

---------------------------
myscript.ahk
---------------------------
Error at line 1606.

The following variable name contains an illegal character:
"SearchWindows[A_Gui].Result"

The program will exit.
---------------------------
OK   
---------------------------
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: wrong syntax - why?

11 May 2021, 21:00

theres nothing wrong with it.
uve edited and whittled down ur script to the point that the example no longer contains any errors
braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

Re: wrong syntax - why?  Topic is solved

11 May 2021, 21:22

But I get this error message.

The 3 lines are the only lines of the script where the variable name "Searchwindows" appears.

edit
I removed the line with the error, loaded the file - it loaded without error
Now I put the line back where it was (copy and paste from the original file) , and now, the script loads without error message.

I don't need to understand everything :)
Last edited by braunbaer on 11 May 2021, 21:37, edited 1 time in total.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: wrong syntax - why?

11 May 2021, 21:26

braunbaer wrote:
11 May 2021, 21:22
But I get this error message.

The 3 lines are the only lines of the script where the variable name "Searchwindows" appears.
Error at line 1606? Is there an include file
braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

Re: wrong syntax - why?

11 May 2021, 21:38

There are several include files and it's a big script.
No idea what has gone wrong, but luckily it works now...
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: wrong syntax - why?

11 May 2021, 21:49

braunbaer wrote:
11 May 2021, 21:22
edit
I removed the line with the error, loaded the file - it loaded without error
Now I put the line back where it was (copy and paste from the original file) , and now, the script loads without error message.

I don't need to understand everything :)
:roll: if uve changed nothing, uve fixed nothing

somewhere in ur script, u probably had(note the legacy assignment):

Code: Select all

x=SearchWindows[A_Gui].Result
...
%x% := ...
but unless ure developing with a VCS we cant know what(if anything) changed since
braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

Re: wrong syntax - why?

11 May 2021, 22:27

swagfag wrote:
11 May 2021, 21:49
if uve changed nothing, uve fixed nothing
Thats what I would have believed. Obviously, there must have been a change.
swagfag wrote:
11 May 2021, 21:49
somewhere in ur script, u probably had(note the legacy assignment):
No. I've posted the error message, which shows the line number of the error (it's the last code line I posted in the opening posting of the thread) and what the "incorrect variable" looks like:
The following variable name contains an illegal character:
"SearchWindows[A_Gui].Result"

Even if I had made a legacy assignment (which certainly is not the case), that would not explain the error message I got.

swagfag wrote:
11 May 2021, 21:49
%x% := ...
lol...
BTW, this would give a runtime error, but would not produce an error message when the script is loaded.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: wrong syntax - why?

11 May 2021, 22:52

there must have been a change.
well, not necessarily. the error complains about trying to declare a variable whose name is what-u-see-in-the-error-message(which happens to include illegal characters, ie [, ] and .)
if a code path is taken where u don't try to declare such a variable, obviously no error shall be emitted. for all i care, ur script might as well have executed with no errors the very next time u ran it, without having changed anything at all. i dont have ur script, so its pointless to speculate

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: metallizer and 129 guests