Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Morgal
Beginner


Joined: 06 Nov 2006
Posts: 26

PostPosted: Wed Nov 08, 2006 1:58 pm   

[1.13] #PSUB Question
 
#TRIGGER {(x)(y)} {#PSUB "%2"}

Now, this trigger should essentially just remove x from the line and leave me with y (which it does do).

However, it is also causing the line it below to be appended to the end of the one being #PSUBed.

So if the MUD output:
xy
abc

I want:
y
abc

But I get:
yabc

With the trigger on.

Is this correct? If so, how do i put the new line back in? I tried %concating the #PSUB with a %{cr} but the result wasn't good (it appeared to hide the next line.

Or if this isnt correct.. then is it a bug?

Morgal
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Nov 08, 2006 6:10 pm   
 
In CMUD, the " quotes are used for literal strings. Variables and functions (like %2) are NOT expanded within quotes. This was normally the rule in zMUD, but the %1..%99 were exceptions that broke the rules. This exception isn't allowed in CMUD.

Because the "" were a kludge in zMUD, you can mostly just remove them in CMUD. The following syntax is the correct way to do it in CMUD:
Code:
#TRIGGER {(x)(y)} {#PSUB %2}


However, the other problem you have is that you should be using #SUB and not #PSUB. Look at the help file for #PSUB...you are not using it correctly. #PSUB takes arguments for the x position of the start and end of the substitution. If you look a the help file for #SUB, you will see more of what you want.

So, your CORRECT trigger is this:
Code:
#TRIGGER {(x)(y)} {#SUB %2}
Reply with quote
Morgal
Beginner


Joined: 06 Nov 2006
Posts: 26

PostPosted: Thu Nov 09, 2006 9:08 am   
 
Thanks Zugg,

Just letting you know that taking out/putting in the " " around %2 makes no difference to the way cMUD handles the trigger. So it appears the variables ARE being expanded. (Is this a bug? As you said they weren't expanded)

I know you are supposed to use start and end values for it, but, to quote your help file:
"If XStart is omitted, the beginning of the line is used. If XEnd is omitted, the end of the line is used."

So it is valid (although not intended).

Anyway, what I actually intended by making this topic appears to have got lost along the way. My point is.. that if #PSUB is used, and it isnt given a specific end, it eats the end of line characters.

This can be shown by
Code:
#TRIGGER {Anything you want} {#PSUB 0 1000}

or
Code:
#TRIGGER {Anything you want} {#PSUB 0}


I.e. the end of line specified is beyond the actual end of line that is being subbed or, no end is specified then it eats the end of line characters.

Now, if #PSUB was never intended to be given a value that *could* be beyond the end of the line then fair enough, its silly of me to have tried it. But this is a beta.

Anyway, ill end this ramble now.
Morgal
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Nov 09, 2006 5:21 pm   
 
Thanks for the extra info. Yes, you are right about how it should work with the XStart and XEnd omitted, so the fact that it seems to eat the following lines is a bug.

I'll check the "%1". It isn't supposed to be working in CMUD, so this might be a bug too. There are some commands that actually treat their arguments as literal values and then parse them themselves, so maybe that's it. Or, maybe I forgot and added code to the parser to allow %1..%99 in quotes. It's been almost a year since I wrote the core parser for CMUD, and it's possible that I added something and forgot about it. Anyway, I'll check into it.
Reply with quote
Morgal
Beginner


Joined: 06 Nov 2006
Posts: 26

PostPosted: Thu Nov 09, 2006 5:53 pm   
 
Just to clarify, it doesnt eat the following lines, it just eats the end of line characters.

Morgal
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Nov 09, 2006 8:07 pm   
 
Actually, when I tested your first example, it never displayed the "abc" on the following line. I did this:

Code:
#TRIGGER {(x)(y)} {#PSUB %2}
#SHOW xy%{cr}abc

and it ate the "abc". But in any case, it's on the bug list.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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