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
Zafrusteria
Wanderer


Joined: 11 Oct 2000
Posts: 94
Location: United Kingdom

PostPosted: Sun Feb 29, 2004 10:20 am   

problem with =~
 

#alias test_bug
#IF ("%1" =~ "foobar") {#SHOW true foobar = "%1"}
#IF ("%1" =~ "true foobar") {#SHOW true true foobar = "%1"}
#IF ("%1" =~ "false foobar") {#SHOW true false foobar = "%1"}

when run with: test_bug "true foobar"

The output is this, can anyone explain why?

true foobar = true foobar
true true foobar = true foobar
true false foobar = true foobar

From the Help text "v1 =~ v2 true if the string v1 matches the pattern in v2
"

Clearly in the example above v1="false foo bar" should not match with v2="true foobar"
Reply with quote
Zafrusteria
Wanderer


Joined: 11 Oct 2000
Posts: 94
Location: United Kingdom

PostPosted: Sun Feb 29, 2004 10:40 am   
 
also this seems wrong too but using an exact match

alias test_bug
#SHOW %1
#IF ("%1" = "monster") {#SHOW buggy} {#SHOW correct}
#IF ("%1" = "a") {#SHOW buggy} {#SHOW correct}

run with test_bug "a monster"

Output is
a monster
buggy
buggy

Again how can "a monster" be equal to "a" and "monster".


this is even more bazar
call with test_bug "a fred"

get the output

a fred
buggy
buggy

not sure how "fred" = "monster"
Reply with quote
m_orb
Beginner


Joined: 13 Jan 2003
Posts: 28

PostPosted: Sun Feb 29, 2004 1:56 pm   
 
use "%-1" in place of "%1" while testing a couple of words
#IF ("%-1" =~ "true foobar") {#SHOW true true foobar = "%-1"}
and test without quotation marks:
test_bug true foobar
Reply with quote
Zafrusteria
Wanderer


Joined: 11 Oct 2000
Posts: 94
Location: United Kingdom

PostPosted: Sun Feb 29, 2004 2:22 pm   
 
Thanks for the answer,

I found it in the help file too Smile
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Mar 01, 2004 4:44 am   
 
Also you should understand that quotes and braces are included in the arguments of alias.

#AL Example {#ECHO %char(%ascii("%1"))}
Example "a"
returns: "
Example {a}
returns: {

If you remove the quotes in the alias then the parser will strip whatever delimeter was used when calling the alias.
#AL Example {#ECHO %char(%ascii(%1))}
Example "a"
returns: a
Example {a}
returns: a
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