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

#IF fails when variable contains quote-marks

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



Joined: 06 Dec 2010
Posts: 66
Location: Next to polarbear

PostPosted: Sat Oct 27, 2012 6:15 am    Post subject: #IF fails when variable contains quote-marks Reply with quote

When a variable contains a string with quotes (" or '), the string-match does not work when used quote matches with quotes used in code. This goes as far as into nested variables.

Code:
#var test {this "string" contains quotes}
#if {"$test"!=""} {#showme This should print}

#var test2 {{first}{{0}{value}{1}{another "value"}}}
#if {"$test2"!=""} {#showme This as well should print, but nothing}
#if {"$test2"==""} {#showme Even this doesn't work!}


And even debug shows nothing that would explain about what goes wrong. (I spent some time with trying to figure out what went wrong)

With nested variable, it's possible to round with this:
Code:
#if {&test[]} {...}

With unnested variables, I don't know any way. Juggling with single vs. double is not a solution, especially since a string can contain both.
Quote:
It's "time".


To make it even funnier, I tested this, and it works:
Code:
#var test {"!="1"}
#if {"$test} {#showme Sort of amusing.}

Although...
Code:
#var test {"!=""}
#if {"$test}
   {#showme Oddly, this does not work.}
   {#showme But this does.}



Tintin++ 2.00.8
Ubuntu 10.04
Back to top
View user's profile Send private message Visit poster's website AIM Address
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Sat Oct 27, 2012 6:32 am    Post subject: Reply with quote

Probably best to use #regex instead of #if for string comparisons.
Back to top
View user's profile Send private message Send e-mail
F-3000



Joined: 06 Dec 2010
Posts: 66
Location: Next to polarbear

PostPosted: Sat Oct 27, 2012 8:26 am    Post subject: Reply with quote

How you would write the #regex test?
Back to top
View user's profile Send private message Visit poster's website AIM Address
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3796

PostPosted: Sun Oct 28, 2012 1:18 pm    Post subject: Reply with quote

Code:
#regex {$test} {^$} {#showme empty} {#showme not empty}
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