Erroneous error message?

Report problems with documented functionality
Rohwedder
Posts: 2698
Joined: 04 Jun 2014, 08:33
Location: Germany

Erroneous error message?

10 Dec 2019, 06:18

Hallo,

Code: Select all

MsgBox, "Hallo"
MsgBox,% "Hallo"
Switch
results in an error message with:
001: MsgBox,"Hallo"
002: MsgBox,"Hallo"

I miss the percentage sign that forces an expression in line 002.
User avatar
lmstearn
Posts: 301
Joined: 11 Aug 2016, 02:32
GitHub: lmstearn
Contact:

Re: Erroneous error message?

12 Dec 2019, 22:55

In 1.1.32.00 the error is:
Error: Missing "{"

Line#
001: MsgBox,"Hallo"
002: MsgBox,"Hallo"
---> 003: Switch
004: Exit
005: Exit
005: Exit

The program will exit.
It's the same error if the % is omitted. Switch wants the cases:
https://www.autohotkey.com/docs/commands/Switch.htm wrote:Switch SwitchValue
{
Case CaseValue1:
Statements1
Case CaseValue2a, CaseValue2b:
Statements2
Default:
Statements3
}
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
just me
Posts: 6804
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Erroneous error message?

13 Dec 2019, 06:19

IMO, the script parser removes the force-an-expression % signs when the line is executed and stored in the most-recently-executed buffer.

Code: Select all

#NoEnv
ToolTip, "Hello"
ToolTip, % "Hello"
Var = % "Hello"
ListLines
Pause

Esc::
ExitApp
lexikos
Posts: 6682
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Erroneous error message?

08 Feb 2020, 00:06

ListLines and the error messages show a rough reproduction of the source code based on the "semi-compiled" state of the script. The text of each expression is kept, but the overall text of commands is not; it is reproduced from the command index and text of each parameter. Each parameter might have its original text (always excluding the force-an-expression sign) or might be derived from a variable name (for input/output variables).

It is not intended to be 100% accurate, but perhaps it is worth adding the % prefix for expression parameters. Whether or not the prefix was originally used is not stored anywhere, so parameters that are expressions by default would either always or never have the prefix.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 14 guests