Hallo.
Why this line works:
sText := "; "
and this generates error:
sText := "; ;"
?
Why this assign line no works?
Re: Why this assign line no works?
Because a ; with a space or tab in front starts an inline comment. At script start, the interpreter removes all comments from the script version in memory that it will actually run. Try instead to escape the ; :
Code: Select all
sText := "; `;"
Re: Why this assign line no works?
But
";"
is not
;
in front! Then it is not a comment...
";"
is not
;
in front! Then it is not a comment...
Re: Why this assign line no works?
https://www.autohotkey.com/docs/v1/Language.htm#comments wrote:Scripts can be commented by using a semicolon at the beginning of a line. For example:
; This entire line is a comment.
Comments may also be added at the end of a line, in which case the semicolon must have at least one space or tab to its left. For example:
Run Notepad ; This is a comment on the same line as a command.
[...]
Since comments are ignored when a script is launched, they do not impact performance or memory utilization.
Re: Why this assign line no works?
Hi
Programming languages are based on rules and at the same time on the hierarchy of such rules, where the secondary ones have to abide by the superior ones in the hierarchy. Said rules do not have to be logical outside of their own language. It may even seem counter-intuitive (or stupid), without understanding such rules and their hierarchies.
Archimede, has found one of those paradoxes.
The language of programming has the same meaning as politics or a religion: from the outside —the non-learned or non-"believer"—it seems to make no sense. The same for the customs of each culture.
Programming languages are based on rules and at the same time on the hierarchy of such rules, where the secondary ones have to abide by the superior ones in the hierarchy. Said rules do not have to be logical outside of their own language. It may even seem counter-intuitive (or stupid), without understanding such rules and their hierarchies.
Archimede, has found one of those paradoxes.
The language of programming has the same meaning as politics or a religion: from the outside —the non-learned or non-"believer"—it seems to make no sense. The same for the customs of each culture.
Re: Why this assign line no works?
It's a simple rule.
Consider:
How should AHK decide if ; covfefe is part of the msgbox text or an inline comment? It simply follows the language rules, in an order determined by a known algorithm.
The human user can do the same, and if they decide that it should be part of the message, they can use the documented AHK escape procedure.
If you use a code box, you already get a visual hint:
(That doesn't mean that code boxes work perfectly - but here it could help to understand the problem. A good code editor, with working AHK syntax rules, can show you the same.)
Consider:
Code: Select all
msgbox hello ; covfefe
The human user can do the same, and if they decide that it should be part of the message, they can use the documented AHK escape procedure.
If you use a code box, you already get a visual hint:
Code: Select all
sText := "; ;"
sText := "; `;"