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

BUG: String comparisions fail with embedded newlines.

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



Joined: 10 Apr 2011
Posts: 365
Location: As "Jomin al'Bara" in WoTMUD or Wiltshire, UK

PostPosted: Wed Jun 22, 2011 7:00 pm    Post subject: BUG: String comparisions fail with embedded newlines. Reply with quote

Nasty little glitch, this, as I was using equivalence checks on multi-line room description strings from a MUD for various purposes and always getting a non-equivalence result even when what I was comparing WAS the same:
Code:
#if {"ABC"=="ABC"}{#showme {True}}{#showme {False}}
True

#if {"ABC\nABC"=="ABC\nABC"}{#showme {True}}{#showme {False}}
False

And to further investiage:
#if {"ABC\nABC">"ABC\nABC"}{#showme {True}}{#showme {False}}
False

#if {"ABC\nABC"<"ABC\nABC"}{#showme {True}}{#showme {False}}
False

It was really weird when I effectively got #IF {"$ASTRINGVALUE"=="$ASTRINGVALUE"} always choosing the #ELSE choice...
As a tempory workaroud I'll have to created a #FUNCTION that will split two strings into individual characters in two #LIST variables with two #PARSE loops and then do a byte by byte comparision with a #LOOP. Unless there is an easier way? I guess string character functions are not a high demand item for TinTin generally.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Wed Jun 22, 2011 11:26 pm    Post subject: Reply with quote

Easiest is probably:
Code:

#line sub escape #if {"a\nb" == "a\nb"} {#showme true}


or:
Code:

#if {"a\nb" == "a\\nb"} {#showme true}

The problem is that the first argument is treated as plain text. My memory is kind of blurry, but I think there was a reason for doing so.
Back to top
View user's profile Send private message Send e-mail
Slysven



Joined: 10 Apr 2011
Posts: 365
Location: As "Jomin al'Bara" in WoTMUD or Wiltshire, UK

PostPosted: Thu Jun 23, 2011 3:51 pm    Post subject: Reply with quote

I've got what you are saying - if I go down the #LINE SUB solution route I'll also need to include the VARIABLE option:
Code:
#VARIABLE valA {ABC\nABC};
#VARIABLE valB {ABC\nABC};
#LINE SUB {ESCAPE;VARIABLE} {#IF {"$valA"=="$valB"}{#SHOWME {True}};#ELSE {#SHOWME {False}}}
True
Thanks for that, should be easy to fix my stuff with this. Coffee
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Thu Jun 23, 2011 5:16 pm    Post subject: Reply with quote

#if will substitute the variables, so #line sub escape should suffice.
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