error ONLY when compiled Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
payaAHK
Posts: 106
Joined: 30 Oct 2016, 15:28

error ONLY when compiled

Post by payaAHK » 15 Sep 2023, 09:52

hello
i have a little script, who was running well else compiled or in ahk.
i use it from about 3 years
i recompiled it last week, for changing its name (no changes in the script itself)
the script works well in AHK
it is compiled without any warning
BUT when i lauch the exe i get warning window, with:
---------------------------
Scan_button_ex.exe
---------------------------
Error at line 288.

Line Text: "}
Error: Missing close-quote

The program will exit.
---------------------------
OK
---------------------------
line 288 is in a comment block
how find the error ?
please help

User avatar
mikeyww
Posts: 27274
Joined: 09 Sep 2014, 18:38

Re: error ONLY when compiled

Post by mikeyww » 15 Sep 2023, 12:05

Hello,

One cause of differences with compiled scripts can be how antivirus software handles them, but does not sound like the case here. Some of the built-in variables differ, too.

One way towards progress here could be to post your script, as other readers could have a look at it.

More clues:
viewtopic.php?t=69725
https://www.autohotkey.com/board/topic/83374-how-to-escape-quotation-marks/
https://www.autohotkey.com/board/topic/54292-missing-close-quote-assistance/
viewtopic.php?style=1&t=99119

TAC109
Posts: 1128
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: error ONLY when compiled

Post by TAC109 » 15 Sep 2023, 19:10

@payaAHK

Compiled script line numbers are affected by any #included files, as the compiler simply includes the code from the file at the appropriate place, which will change the line numbers from then on. Also the compiler removes unnecessary blank lines and comments from the compiled script.

If the compiled .exe is not compressed or protected in any way, a utility such as Resource Hacker can be used to examine the compiled script (look at the item under RCData). This will enable you to determine what is going on at line 288.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe

payaAHK
Posts: 106
Joined: 30 Oct 2016, 15:28

Re: error ONLY when compiled

Post by payaAHK » 16 Sep 2023, 05:42

@mikeyww
the code is quite simple but quite long, it would take someone a lot of good will to dissect it and find the error.
@TAC109
i will try it

payaAHK
Posts: 106
Joined: 30 Oct 2016, 15:28

Re: error ONLY when compiled

Post by payaAHK » 16 Sep 2023, 05:54

1 read the script in resource hacker
2 copy
3 paste in ahk editor and check the structure
line 288:
image.png
image.png (9.18 KiB) Viewed 602 times
and when unfolding:
image.png
image.png (35.34 KiB) Viewed 602 times
no error in the structure...

strange, the nested {} are the same ones in compiled or not compiled script ?

TAC109
Posts: 1128
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: error ONLY when compiled  Topic is solved

Post by TAC109 » 16 Sep 2023, 17:25

The original error message indicated that the line in question was "}. There may be a hidden Unicode character on that line, so find that line in a hex editor (or directly in Resource Hacker in binary view) and check that there are no extraneous hex characters around that line.

You could also find that line in your original source and delete it then retype the line } and maybe also the preceding and following lines. (It is important to delete and retype rather than copy & paste.) See if this helps after recompiling.

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe

User avatar
DevWithCoffee
Posts: 55
Joined: 13 Oct 2020, 12:16

Re: error ONLY when compiled

Post by DevWithCoffee » 16 Sep 2023, 20:03

I had a similar problem, both in Script and Compiled, so I always wrote it this way:

Code: Select all

; New Function
MyFunction(name)
{
    MsgBox % "Hello " name
}

; Conditions
if(v == 1)
{
    MsgBox Working!
}

; Simple
Loop
{
    Tooltip % "Clock: " A_Hour ":" A_Min ":" A_Sec, % A_ScreenWidth, % A_ScreenHeight
}
These are just examples.
As I spent a long time programming codes with Javascript, I always had the habit of using { }

payaAHK
Posts: 106
Joined: 30 Oct 2016, 15:28

Re: error ONLY when compiled

Post by payaAHK » 17 Sep 2023, 03:58

@TAC109
it works!
i have erased last } and blank lines under it
i rewrote the same
and it works again

thank you :bravo:

the origin of the bug is still mysterious

User avatar
mikeyww
Posts: 27274
Joined: 09 Sep 2014, 18:38

Re: error ONLY when compiled

Post by mikeyww » 17 Sep 2023, 06:33

Why did the script work without compiling, and not work when compiled?

TAC109
Posts: 1128
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: error ONLY when compiled

Post by TAC109 » 17 Sep 2023, 18:46

@mikeyww
Also, why didn’t the compile throw an error? Alas, we will never know for sure as the corrupt compile isn’t available for analysis.

@payaAHK
Thanks for advising that replacing those lines in the source fixed the problem. :thumbup:

Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe

Post Reply

Return to “Ask for Help (v1)”