|
crycry Apprentice
Joined: 24 Jun 2006 Posts: 169 Location: UK - South Coast
|
Posted: Wed Nov 29, 2006 2:51 pm
[1.17] clickable hyperlink trigger |
Hey all, below is my hyperlink trigger that worked in zMud, but I cant get it to work in cMud, could you have a look please? cMud reports an unmatched braces error. Be buggered if i can see it.
pattern: (%q)({http://|ftp://|telnet://|www.}%x)(%q)
script : #SUBSTITUTE {<A '%quote(%2)'>%1%2%3</A>}
much thankies :) |
|
|
|
crycry Apprentice
Joined: 24 Jun 2006 Posts: 169 Location: UK - South Coast
|
Posted: Wed Nov 29, 2006 3:04 pm |
lovely, while tring to sort my classes into packages (the move function doesnt work) cmud crashed, corrupted the settings file, and the layout file.. 5 hours of work gone. much annoyed.
|
|
Last edited by crycry on Wed Nov 29, 2006 3:09 pm; edited 1 time in total |
|
|
|
bortaS Magician
Joined: 10 Oct 2000 Posts: 320 Location: Springville, UT
|
Posted: Wed Nov 29, 2006 3:05 pm |
Yup, beta software does that. Backup, backup, backup, but you already knew that.
|
|
_________________ bortaS
~~ Crusty Klingon Programmer ~~ |
|
|
|
crycry Apprentice
Joined: 24 Jun 2006 Posts: 169 Location: UK - South Coast
|
Posted: Wed Nov 29, 2006 3:11 pm |
yup :) i did know, and i didnt do it lol
its not a massive setback, i was just excited that id gone more than 3 hours without it happening this time. |
|
|
|
crycry Apprentice
Joined: 24 Jun 2006 Posts: 169 Location: UK - South Coast
|
Posted: Wed Nov 29, 2006 3:31 pm |
odd, woudlnt let me reconnect to the charactor even with a totally new session created.. so reinstalled cmud, and no problem, even with the old files.
much oddness. |
|
|
|
The Raven Magician
Joined: 13 Oct 2000 Posts: 463
|
Posted: Wed Nov 29, 2006 6:20 pm |
crycry, try marking the brackets <> with ~ to quote them, or using %concat() to merge everything.
Code: |
#SUBSTITUTE {~<A '%quote(%2)'~>%1%2%3~</A~>}
#SUBSTITUTE {%concat("<A '",%quote(%2),"'>",%1%2%3,"</A>"} |
|
|
|
|
crycry Apprentice
Joined: 24 Jun 2006 Posts: 169 Location: UK - South Coast
|
Posted: Wed Nov 29, 2006 6:32 pm |
I thought that too Raven, but no joy at all.. but will try the concat idea. thx :)
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Nov 29, 2006 6:37 pm |
The < and > characters shouldn't be treated as special characters in CMUD, so I'm not sure the ~ is needed. This change was made specifically to allow HTML/MXP syntax without having to escape all the brackets.
What I think is happening is that the > character after the %quote function is getting interpreted as a "greater than" logical test. In CMUD, it's more important to put quotes around literal strings, and to use the %concat function like The Raven suggested.
I'll still put this on the bug list because it shouldn't be treating > as a greater-than character in this case and it's really a parser bug. |
|
|
|
The Raven Magician
Joined: 13 Oct 2000 Posts: 463
|
Posted: Wed Nov 29, 2006 7:00 pm |
Perhaps, since quoting portions of text is more important now in CMUD, you could provide some syntactic sugar for the %concat() function? We need a less verbose way to use it, since we use it so often now.
You need a concat symbol... like & in Basic, or + in Perl. Can you overload the + symbol, so if either side of the operator is a string, it becomes a concat operator? |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Nov 29, 2006 7:04 pm |
Actually, you *can* use the + in CMUD for concat (and also in zMUD I believe).
#SHOW %eval("a"+"b")
will display "ab"
However, when I tried it in the above #substitute command, it still gave an error, which is probably related to the same parser problem that gives an error for > when it shouldn't.
So yes, there is a shortcut to concat, but it seems to have trouble in some situations. |
|
|
|
The Raven Magician
Joined: 13 Oct 2000 Posts: 463
|
Posted: Wed Nov 29, 2006 8:06 pm |
But can you use the + in braces, without the %eval()? If we put () around it will that work (I think () = %eval)
|
|
|
|
crycry Apprentice
Joined: 24 Jun 2006 Posts: 169 Location: UK - South Coast
|
Posted: Wed Nov 29, 2006 9:22 pm |
excellent, thanks guys for the help. im not overly worried about it working right now so ill wait for you to iron out the parser bug. Thanks again.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Nov 29, 2006 10:33 pm |
Quote: |
But can you use the + in braces |
Well, no, not really. The + is an expression operator. So it's only valid within expressions. The braces {} are not evaluating an expression...they just act like normal " quotes where function and variable expansion is allowed.
If you have done any PHP programming, think about the difference between ' and " in PHP. The single ' quote is for literal strings...no variable expansion. The double " quote allows variable expansion and is like {} in CMUD. Now, PHP uses the . operator for concat. So in PHP you can do this:
Code: |
PHP: $var = 'literal string' . "string with $a variable"
CMUD: var = "literal string" + {string with @a variable} |
But PHP doesn't recognize the . operator within the " string, just like CMUD doesn't recognize + within the {} string.
So, how do you turn on expression evaluation in CMUD? With () parenthesis. So yes, you could do this:
Code: |
#sub ("<A '"+%quote(%2)+"'>"+{%1%2%3}+"</A>") |
and this actually compiles and works.
So yes, Raven got the answer correct with putting () around it and then using + for concat. |
|
|
|
crycry Apprentice
Joined: 24 Jun 2006 Posts: 169 Location: UK - South Coast
|
Posted: Wed Nov 29, 2006 10:40 pm |
your all a whole lot cleverer than me thats for sure, thanks lots.
i tried that zugg and it worked but put a +{ }+ around the link. i tried #sub ("<A '"%quote(%2)"'>"%1%2%3"</A>") and it worked fine. is this still legal and, more importantly, sensible? |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Nov 30, 2006 1:20 am |
Yeah, that will work, although I'll need to check on the extra {}...that's probably another bug. But the implied concat syntax that is working with () is also supposed to work for {}, so you can certainly use that as a work-around until the {} is fixed.
|
|
|
|
|
|