TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

spaces causing blank lines to be sent to the session

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
davevnj



Joined: 22 Nov 2006
Posts: 55

PostPosted: Tue Dec 19, 2006 12:36 am    Post subject: spaces causing blank lines to be sent to the session Reply with quote

I know we've had a few of these before, but just wanted to point out the following code, causes a carriage return to be sent to the session:
Code:
#ALIAS {autoheal}
{
   #IF {"$aff_prone" == "1"}
   {
      queue stand;
   } {
   #IF {"$aff_bleeding" == "1"}
   {
      queue clot;
   }; };
};


while the following does not:
Code:
#ALIAS {autoheal}
{
   #IF {"$aff_prone" == "1"}
   {
      queue stand;
   } {
   #IF {"$aff_bleeding" == "1"}
   {
      queue clot;
   };};
};


In my test, both IF conditions evaluate to false.
Note the difference in the second to last line.
Back to top
View user's profile Send private message Visit poster's website
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Tue Dec 19, 2006 5:23 am    Post subject: Re: spaces causing blank lines to be sent to the session Reply with quote

You use ';'s where they shouldn't be used. Also, tintin is correctly sending a carriage return because that's what your code indicates. If it wasn't for a hack in the parser your script would actually be sending 4 carriage returns.

Try the following instead:

Code:
#ALIAS {autoheal}
{
   #IF {"$aff_prone" == "1"}
   {
      queue stand
   } {
   #IF {"$aff_bleeding" == "1"}
   {
      queue clot
   } }
}
Back to top
View user's profile Send private message Send e-mail
davevnj



Joined: 22 Nov 2006
Posts: 55

PostPosted: Tue Dec 19, 2006 9:43 am    Post subject: Reply with quote

I guess I just think like a programmer... ";" to me, means end of statement, rather than separate commands.
Code:
#alias {test}
{
        #IF {"$test1" == "1"}
        {
                #showme test1
        }
        #IF {"$test2" == "1"}
        {
                #showme test2
        }
}


gets translated into
Code:
#ALIAS {test}={#IF {"$test1" == "1"}{#showme test1}#IF {"$test2" == "1"}{#showme test2}} @ {5}

The parser knows to look for new statements while parsing the if, but look what happens when I throw a monkey wrench of doom:

Code:
#alias {test}
{
        #NOP Monkey Wrench of DOOM
        #IF {"$test1" == "1"}
        {
                #showme test1
        }
        #IF {"$test2" == "1"}
        {
                #showme test2
        }
}


Now the #NOP needs a ";" or the whole alias is commented out. The result is that I have to be very aware of when and where I'm putting my semi-colons. While that is ok, it would be nice if I could consistantly use them all over the place without worry. (Especially since some of the bigger #IF blocks are really going to need the commenting.)

I guess my only question is, if I eliminate the space as I did in the first example, will that "hack" always be there in the foreseeable future?
Back to top
View user's profile Send private message Visit poster's website
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Tue Dec 19, 2006 5:46 pm    Post subject: Reply with quote

davevnj wrote:
I guess I just think like a programmer... ";" to me, means end of statement, rather than separate commands.


Well, in c 99.9% of the programmers don't place semicolons after braces if it's not required, so you can consistently use semicolons if you exclude braces.

davevnj wrote:

I guess my only question is, if I eliminate the space as I did in the first example, will that "hack" always be there in the foreseeable future?


Semicolons after braces will likely end up breaking your scripts when I add support for pre-compiled scripts, that might be a while though.

The hack for semicolons at the end of command strings is likely to stay.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group