|
tessellated Beginner
Joined: 19 Feb 2005 Posts: 12
|
Posted: 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 |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: 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 |
|
|
|
mr_kent Enchanter
Joined: 10 Oct 2000 Posts: 698
|
Posted: 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 |
|
|
|
mr_kent Enchanter
Joined: 10 Oct 2000 Posts: 698
|
Posted: 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 |
|
|
|
|
|