Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Vittorio
Beginner


Joined: 22 Oct 2003
Posts: 10

PostPosted: Fri Dec 12, 2003 5:42 pm   

More questions about functions.
 
Strangeness. It doesnt quite behave as I expect it to.

I defined a function as follows:

#VAR test {%if( %1=~ "cat", %1, 0)} {_nodef}

Basically i'm trying to pattern match the letters "cat" from the parameter passed to @test().

@test(cat) = cat (true - expected)
@test(catnip) = catnip (true - expected)
@test(dog) = 0 (false - expected)
@test(no kitty) = no kitty (true!?)

Why the heck is the last example a match? Everything returns true if I pass anything longer than one word as a parameter. Does pattern matching not work in this case or something?

I understand I can use %pos to avoid the aforementioned problem in the example. However, I would like to pattern match using wildcards, so =~ is preferable.


-V.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Dec 12, 2003 7:10 pm   
 
#FU test {%if( "%1" =~ "cat", "%1", 0)}
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net