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
tessellated
Beginner


Joined: 19 Feb 2005
Posts: 12

PostPosted: Sat Feb 19, 2005 7:29 am   

Next string vs. special char question
 
Ok, now I want to test an alias's parameter to see if it begins with the "~" character, but I dont know how to make zmud behave well.


Code:
#IF (%begins( %1, ~~)) {#say true} {#say false}


The above always results in false even when given ~foo as input
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Feb 19, 2005 8:46 am   
 
#IF (%begins("%1","~")) {#SAY true} {#SAY false}

if you type this in #echo ~a test

it will True (if trigger on trigger?) and then false because ~ is a special char

#Echo ~~a test should fire two trues

I can't test this because of certain malicious spyware problems *Glare* hopefuylly I will have it all straightened up shortly
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Sat Feb 19, 2005 9:01 am   Re: Next string vs. special char question
 
The problem is not that you can't match the ~ character. The problem is that there is no ~ character in the parameter to match. The parser has already removed the ~ character and forced foo to be literal.

If you're entering the alias and parameter at the command line, you'll need to escape the ~ character there as well.

If you're calling the alias from another setting, you'll again have to escape the ~ character.

Code:
Alias test {#IF %begins( %1, ~~ ) {#SAY true} {#SAY false};#SHOW %1}


test ~foo
false
foo


test ~~foo
true
~foo
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Sat Feb 19, 2005 9:24 am   Re: Next string vs. special char question
 
Variables are not parsed in the command line, but variable assignment is, so

Code:
#VAR vtest "~foo"
#VAR vtest2 "~~foo"
#VAR vtest3 "~~~foo"
#VAR vtest4 "~~~~foo"
#VAR vtest5 "~~~~~foo"
#VAR vtest6 "~~~~~~foo"
#Alias test {#IF %begins( %1, ~~ ) {#SAY true} {#SAY false};#SHOW %1}


test @vtest The value of vtest is: foo
false
foo


test @vtest2 The value of vtest2 is: ~foo
true
~foo


test @vtest3 The value of vtest3 is: ~foo
true
~foo


test @vtest4 The value of vtest4 is: ~~foo
true
~~foo


test @vtest5 The value of vtest5 is: ~~foo
true
~~foo


test @vtest6 The value of vtest6 is: ~~~foo
true
~~~foo
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