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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Michael Nelson
Novice


Joined: 03 Oct 2005
Posts: 36

PostPosted: Thu Oct 09, 2008 2:24 am   

MXP <send>
 
Hi <send> seems to have changed. I can't get it to send commands with variables. I can assign the send string to an alias and that works fine but it seems like bad coding practice as what I am really sending is a variable. Basically I want to do this <send "@myvar">sendmyvar</send> or maybe something like <send "kill @myvar"> etc.

Thanks
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Oct 09, 2008 3:44 am   
 
What works for me is this:

#MXP %concat("<send """,@myvar,""">Sendmyvar</send>")

Just concatenate them together and you should have no problems.

Charneus
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Oct 09, 2008 7:48 am   
 
You can, but that looks damn UGLY. You can just use ' instead of " inside MXP tags. " is used to delimit a literal string, so when you say "@myvar" you're saying "the string '@myvar'" rather than "the contents of the variable @myvar". You're looking for <send '@myvar'>.

You should notice in the editor that the @myvar variable will turn blue and you'll be able to click the name to go to the contents of the variable (it might also be red if the variable doesn't exist yet). If it's like that, it means that the contents of the variable will be used. If it's in green, that means the literal string will be used.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Oct 09, 2008 2:30 pm   
 
Don't know what I'm doing wrong, then, because your suggestion doesn't work, whereas mine works perfectly.

This is what I used:

#VAR testvar "#SAY This test worked."
#MXP {<send '@testvar'>Test MXP</send>}

All that returns is:

<send '#SAY This test worked.'>Test MXP</send>

whereas with mine, it would return:

Test MXP //as a link
This test worked. //after clicking the link.

Perhaps you can give me some insight on this.

Charneus
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Oct 09, 2008 4:07 pm   
 
...I can't really, except that your example is working fine in my CMUD 2.36 untitled session. Do you have an old version or something loaded that could be interfering?
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Michael Nelson
Novice


Joined: 03 Oct 2005
Posts: 36

PostPosted: Fri Oct 10, 2008 2:46 am   
 
The '' seem to work. Here is another question though. When @myvar is something like Butcher's Shop. is there a way to escape the ' in the string. I tried %replace(@myvar, "'", "~'") but that doesn't work. Thanks again.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Oct 10, 2008 3:39 am   
 
@Fang:

Heh. I found my problem. Somewhere, I had put an apostrophe in the variable. I typed my last post from memory, but looking at it today, I saw that it did have that apostrophe. *sigh*

@Michael:

Not sure how you can escape it within the variable itself, but if you did use my code, then you'd have no problem with apostrophes. Just food for thought. :P

Charneus
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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