 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Jan 31, 2007 11:28 pm
=~ and %%1 |
I've never used this syntax before, so maybe I'm using it wrong. Here's what I'm trying to do:
Alias name: test
Code: |
#if (%2 =~ "(%d)") {#echo NUMBER %%1 %2};#if (%2 =~ "(%w)") {#echo WORD %%1 %2} |
When I input
test blah 97928
I expect this output:
NUMBER 97928 97928
but what I get is this:
NUMBER %%1 97928
Obviously the match is working, but the parameter's not being expanded. Am I doing this wrong?
-------
Secondly, when I input this on the command line:
#alias test {#if (%2 =~ "(%d)") {#echo NUMBER %%1 %2};#if (%2 =~ "(%w)") {#echo WORD %%1 %2}}
the code that ended up in the value box was this:
Code: |
#if (%2 =~"") {#echo NUMBER %2};#if (%2 =~"") {#echo WORD %2} |
Even weirder: I ran the alias command immediately above to create the alias, realised it had gone wrong somehow and manually edited the script to match what I'd intended. I ran it as I described in the previous example and then deleted the setting. When I ran that same alias command again to recreate the alias and see if it'd do it again, I got this:
Code: |
#if (%2 =~"97928 ") {#echo NUMBER %2};#if (%2 =~"97928 ") {#echo WORD %2} |
So am I doing something wrong or is there a bug here?
-----
EDIT: There's definitely a bug here. I tried this code straight from the #if help file:
#var line {You receive 29672896 coins}
#IF (@line =~ "You receive (%d) coins") {split %%1}
and "split %%1" was sent. |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Jan 31, 2007 11:48 pm |
I think the =~ pattern operator might have been removed entirely from CMud. If it wasn't then it should be.
Use %match instead. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Tech GURU

Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Wed Jan 31, 2007 11:54 pm |
Fang... I think you've forget that the %% syntax isn't used in CMUD anymore, and the example in the help file is a carry over form zMUD.
I'm not exactly sure how you'd go about accessing it though.
[edit]
It looks like Vij beat me to it, but here an alternative.
#if (%match(%2, "(%d)", $boo)) {#echo NUMBER $boo %2};#if (%2 =~ "(%w)") {#echo WORD %1 %2} |
|
_________________ Asati di tempari! |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Feb 01, 2007 12:01 am |
Well, Zugg said he'd updated the #IF help file and there's a totally new Expressions help file created today that still lists =~ and explains how to use %%n to access its captured wildcards. Furthermore, =~ still works for matching, you just can't use %%n to access its wildcards.
The entry on the "changes for zMUD users" page that talks about %%n doesn't mention =~, it talks about using the syntax to delay expansion. That's not what I'm doing here.
I'm aware that %match exists, but this syntax is apparently listed as working when it isn't.
EDIT: I've found the answer! Took a little bit of searching but the %%n syntax has indeed been removed and replaced with the %pat function. The help files need updating to reflect that (#IF, Expressions and Pattern Matching all mention it I believe). |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Feb 01, 2007 2:34 am |
Sorry, I haven't done a full read-through of the help entries. The Expressions entry is taken directly from zMUD.
The =~ operation still exists and should still work. But as Fang mentioned, the %%n syntax was replaced with %pat. I just haven't updated all the topics yet. This kind of problem will exist with the help files for a while. It helps to post topics like this so that I will know which topics to edit. I've tried reading through all of the help topics to scan them for problems, but there are *so* many topics to read that the eyes just glaze over pretty quickly. So, the more people looking over the help files, the better. |
|
|
 |
Tech GURU

Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Thu Feb 01, 2007 3:30 pm |
That's good to know, I think I'd missed that command too. Time to change the code On a slightly related note, how do we notify you which entries in the CMUD help needs it's links updated?
[edit] What about those that link to the website instead of linking to the CMUD help? |
|
_________________ Asati di tempari! |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Feb 01, 2007 7:22 pm |
If you see an entry in the CMUD help that needs updated, use the Comment feature in the online web version of the help files. Then you can add a post (same as a forum post). I regularly scan those posts and when I merge your comment into the main help topic text, then I delete the comment.
Don't worry too much about links that open the website instead of opening another CMUD help topic. This happens when there is a link to a topic that doesn't exist yet. If a topic doesn't exist, then it tries to open a web URL instead of just saying "topic doesn't exist". There are still lots of missing topics, and those will be added soon. I'll let your know when I'm ready to have people check for bad links (although I also hope to write a script to look for bad links automatically).
Mainly I'm interested in content changes, such as the %%1 issue, or places where the help files still use & instead of &&, etc. |
|
|
 |
Mixsel Wanderer
Joined: 02 Feb 2003 Posts: 99 Location: Seattle, Wa
|
Posted: Thu Feb 01, 2007 7:39 pm |
So are the help files going use more real life examples?, I still feel Cmud isn't a decent product knowing that a "completly new" program has help files from an old program.
Like how is a non-prgrammer supposed to know how to use forall replace and loop all in one script without having to post and hope someone can give ya the correct answer, this prgram rocks jsut wish the helps would help me out easier lol |
|
_________________ Spin |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Feb 01, 2007 10:00 pm |
If you think the help files need a real life example somewhere, post one or post asking for one if you don't know how to make one yourself. I'm sure someone will provide.
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Feb 02, 2007 12:28 am |
Mixsel: Since every MUD is different, it's very hard to post real-world examples that would make sense to everyone. The CMUD manual *will* have more general scripting help than the zMUD help file. The only help topics I copied from zMUD were the reference topics on the various commands and functions that are the same between CMUD and zMUD (that's called compatibility). Even though there might be some minor differences, it was the quickest way to get a help file for CMUD going initially, rather than writing it all from scratch.
|
|
|
 |
|
|