mIRC Home    About    Download    Register    News    Help

Print Thread
#263096 25/05/18 10:42 PM
Joined: Jul 2014
Posts: 34
S
SykO Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Jul 2014
Posts: 34
Hello, I am currently working on some extension for vs code to add support for mSL, while working on the comments I have discovered the following (not a big breaking) problem:

Code:
test {
  echo -s should be shown in status | /*
  echo -s should not be shown in status | */
}


when executing the previous alias in mIRC 7.52.431 the actual output shows:

Quote:
should be shown in status
should not be shown in status
-
* /*/: not connected to server


when the expected output is:

Quote:
should be shown in status


or

Quote:
should be shown in status
* /*: not connected to server

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
This is a side effect of what I've come to believe is intended behavior. Khaled has stated before that you should not be mixing comments within commands.

To explain whats happening: when used with a pipe it treats everything from the block-comment opening to the end-of-line as a comment but ends the comment at the EOL. If I had to wager a guess, I'd say that internally the same handler used for a line comment(;) is invoked when a block-comment within a set of piped commands is encountered



As an aside, here's my own notes on block comments:

Code:
Valid:
  /* comment
  */
 
Multi-line with trailing text
Unorthodoxed; 'text' is considered part of comment
  /* comment
  */ text
 
Multi-line with trailing text after pipe
Unorthodoxed; '| text' is considered part of comment
  /* comment
  */ | text
 
Proceeded by a pipe
Unorthodoxed: Starts the block comment but terminates at EOL
  command | /* comment

Single line
Invalid: Doesn't terminate the comment
  /* comment */
 
Leading text with whitespace
Invalid: Doesn't terminate the comment
  /* comment
  text */
 
Leading text without whitespace
Invalid: Doesn't terminate the comment
  /* comment
  text*/
 
Proceeded by command
Invalid: Not recognized as a comment
  command /* comment
  */

Last edited by FroggieDaFrog; 26/05/18 12:43 AM.

I am SReject
My Stuff
Joined: Jul 2014
Posts: 34
S
SykO Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Jul 2014
Posts: 34
Thank you, this is actually an interesting thing about comments. I had decided to only allow white spaces as a valid comment (i.e. the comment could only have white spaces on the lines "/*" and "*/" to be a valid comment). I just posted this to see if it was an unintended behavior so that I would reconsider my previous decision.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
More quirks involve using semi-colon instead of /* */.

If the semi-colon is not in the last command of the line, then it's commenting just itself, and the following command gets executed. But if the last command of the line is commented, a curly-brace at the end of that line also gets ignored by the code, but it's not ignored by Ctrl+H checking for mis-matched braces. This situation is also not friendly to an "else" condition on the next line. It took me a long time to trace down a similar error in a script because the code was behaving as if there were mis-matched braces, but Ctrl+H didn't complain about it.

Code:
alias testcomments {
  echo -a yes 1 | /* echo -a no 1 */ | echo -a no 2
  echo -a yes 2 | ; echo -a no 3  | echo -a yes 3
  if (1) { echo -a yes if condition $true A | ; echo -a no 4 | echo -a yes if condition $true B }
  else echo -a yes if condition=false
  if (1) { echo -a yes if condition $true C | ; echo -a no 5 }
  else echo -a not displayed regardless if condition (1) or (0)
  echo -a the rest of this alias is ignored when 2nd if (condition) changed to: if (0)
}

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
This was already reported, multiple times, here: https://forums.mirc.com/ubbthreads.php/ubb/showflat/Number/242045/


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
That page does mention some of what I mention, but it's not pointing out how semi-colon comments are treated differently than slash-asterisks, so I was pointing that out here.

Also, that thread ends with the statement that anything after a comment prefix is treated as a comment. But it's not being treated as the "same" kind of comment. If that alias is edited to remove the pipe symbol and insert a carriage-return to make "; echo -a no 5 }" be on its own separate line, then suddenly Ctrl+H reports a bracket mis-match because now the bracket-match recognizes the end-brace as being within a comment while it formerly did not.


Link Copied to Clipboard