Page 1 of 1

Erroneous error message?

Posted: 10 Dec 2019, 06:18
by Rohwedder
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.

Re: Erroneous error message?

Posted: 12 Dec 2019, 22:55
by lmstearn
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
}

Re: Erroneous error message?

Posted: 13 Dec 2019, 06:19
by just me
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

Re: Erroneous error message?

Posted: 08 Feb 2020, 00:06
by lexikos
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.