Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Bug Report (https://forums.graalonline.com/forums/forumdisplay.php?f=193)
-   -   closing block comments...or not? (https://forums.graalonline.com/forums/showthread.php?t=84693)

salesman 03-15-2009 12:29 AM

closing block comments...or not?
 
Had a weird problem with the serverside portion of a class not working, but the clientside portion worked fine:

After 20 minutes of trying to figure out why the hell my code was freaking out, I found that the problem was commented out information about functions contained in the script:
PHP Code:

/*
//INFO */ 

When writing code, it appears as if the block comment is closed, but when compiled the */ is actually being commented out by the "//"

PHP Code:

/*
//TEST */
function onActionServerSidecmd ) {
  if ( 
cmd == "Test" ) {
    echo(
"Complete");
  }
}
//#CLIENTSIDE
function onMouseDown() {
  
player.chat "Kewl";
  
triggerserver("weapon"this.name"Test"NULL );


Serverside portion would not work with the comments at the top, but the clientside portion would.

Frankie 03-15-2009 05:30 AM

doesn't seem like a bug to me. just a bad use of comment codes. there's no reason why you should use the /* */ if you're just going to use // vice versa.

Tigairius 03-15-2009 06:39 AM

Anything after // will be comments, so you can't use */ after a // on the same line. Serverside is read separately from clientside, so if you did a /* at the top of a script, it would only comment out until it reaches //#CLIENTSIDE.

If you wanted to comment out a whole script you would have to put a /* at the top and a /* right under //#CLIENTSIDE.

salesman 03-15-2009 06:42 AM

Quote:

Originally Posted by Frankie (Post 1474660)
doesn't seem like a bug to me. just a bad use of comment codes. there's no reason why you should use the /* */ if you're just going to use // vice versa.

I just happened to close a commented line within the block comment when I added more information about the enclosed functions.

The script window telling you that the block comment is closed, but the compiler seeing it otherwise is a bug. And the fact that it only knocked out the serverside portion of the code is even worse...had nothing worked, I could have easily determined that the code was commented out, but that wasn't the case.

Quote:

Originally Posted by Tigairius (Post 1474674)
Anything after // will be comments, so you can't use */ after a // on the same line. Serverside is read separately from clientside, so if you did a /* at the top of a script, it would only comment out until it reaches //#CLIENTSIDE.

If you wanted to comment out a whole script you would have to put a /* at the top and a /* right under //#CLIENTSIDE.

Really?
If I placed /* at the top of a script, everything appears to be commented out in the script window (serverside AND clientside)...but I haven't tested if the clientside portion still works.

I know that // comments out the entire line, but it doesn't change the fact that the block comment appeared to be closed but in fact wasn't

Tigairius 03-15-2009 07:11 AM

Quote:

Originally Posted by salesman (Post 1474675)
Really?
If I placed /* at the top of a script, everything appears to be commented out in the script window (serverside AND clientside)...but I haven't tested if the clientside portion still works.

I know that // comments out the entire line, but it doesn't change the fact that the block comment appeared to be closed but in fact wasn't

Yes, in the script window the syntax highlighting will show that the whole script is commented out, but that's because it's just syntax highlighting. It doesn't really have anything to do with the script itself.

As a good rule of thumb I usually start a line like
HTML Code:

/*
  Comments here.
*/

So each one gets their own line.

salesman 03-15-2009 04:23 PM

Quote:

Originally Posted by Tigairius (Post 1474679)
Yes, in the script window the syntax highlighting will show that the whole script is commented out, but that's because it's just syntax highlighting. It doesn't really have anything to do with the script itself.

As a good rule of thumb I usually start a line like
HTML Code:

/*
  Comments here.
*/

So each one gets their own line.

Yea, it was just carelessness/bad luck on my part that the closing */ ended up on the same line as a previous // comment...at least now someone who has read this can watch out and not make the same mistake of trusting the script window.

EDIT: I thought everything within a block comment was ignored when compiled (isn't that the purpose of comments??)...why would one line comments within the block comment not be ignored?

xXziroXx 03-15-2009 04:26 PM

Quote:

Originally Posted by salesman (Post 1474740)
EDIT: I thought everything within a block comment was ignored when compiled (isn't that the purpose of comments??)...why would one line comments within the block comment not be ignored?

Stefan probably have the engine checking first for //, and secondly /* */, which breaks the latter when the sooner is used within it.

salesman 03-15-2009 04:35 PM

Quote:

Originally Posted by xXziroXx (Post 1474743)
Stefan probably have the engine checking first for //, and secondly /* */, which breaks the latter when the sooner is used within it.

Figured as much...I just wish it was consistent between script window and compiling.

Admins 03-22-2009 12:46 AM

Single-line comments can be used to comment out the end of multi-line comments, for GS1 compatibility. Most other languages don't allow that and the script highlighter is simplier in that regard so it's not supporting it.
The server should display a warning if multi-line comments are not closed, if it's not doing that yet then we can add it.


All times are GMT +2. The time now is 08:18 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.