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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Wed Dec 29, 2010 1:09 pm   

%match not always matching
 
Code:
<alias name="yo" id="62">
  <value>#LOCAL $yo
#IF (%match( "hi", "hi", $yo)) {
  #IF ($yo) {#SAY $yo}
  #SAY yo-ho
  }
$pattern=yo
#IF (%match("yo", $pattern, $yo)) {
  #IF ($yo) {#SAY $yo}
  #SAY yo-ho-ho
  }
$pattern=yo|to|no no|bo
#IF (%match("yo", "{$pattern}", $yo)) {
  #IF ($yo) {#SAY $yo}
  #SAY yo-ho-ho and a bottle of rum
  }</value>
</alias>

For some reason I cant get a match when using a $localVar stringlist in the pattern.
Also, since the pattern matches starting with the first char, shouldn't $yo=1 instead of 2? Or am I looking too close.
_________________
Discord: Shalimarwildcat
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Dec 29, 2010 1:26 pm   
 
"{$pattern}" is a string--$pattern is not expanded. What you need is: %concat("{",$pattern,"}")
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Dec 29, 2010 1:32 pm   
 
The %match will _return_ a 1, but $yo will not be changed because you are not capturing any values in your pattern.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Wed Dec 29, 2010 1:47 pm   
 
figured my own answers... since i have no () its going on pattern length, so 2 is right, and i just need to %concat in the $pattern to make it work:
%concat("({", $pattern, "})")
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Wed Dec 29, 2010 1:48 pm   
 
serves me right for not refreshing first... heh
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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