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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
ccogdill
Beginner


Joined: 16 Jul 2002
Posts: 27

PostPosted: Thu Jul 25, 2002 5:30 am   

comma spam
 
I have the following alias script named say that will alternate the text you say in different colors. The mud used { as an escape charecter for the ascii, rather than & in the help files.

#VAR out ""
#VAR Scheme "Wx"
#VAR Count 0
#WHILE ( %len( %-1)>=@Count) {
#VAR out %concat( @out, "{")
#VAR out %concat( @out, %copy( @Scheme, %mod( @Count, %len( @Scheme))+1, 1))
#VAR out %concat( @out, %copy( %-1, @Count+1, 1))
#ADD Count 1
}
' @out~{x
#VAR out ""

The problem is when I place a comma in the text of the say command it will spam out. For example if I enter the following

say blah,

It sends to the mud the following:
' {Wb{xbl{Wbla{xblah{Wblah{x

It should send:
' {Wb{xl{Wa{xh{W{x,{x

Any ideas why the comma would throw off my message?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jul 25, 2002 10:46 am   
 
You need to put quotes around the %-1.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Jul 25, 2002 2:27 pm   
 
The comma is a special character which is used as a delimiter in functions, such as %copy. When you have a comma inside your text, %copy treats it as a special character leading to the problem you describe. Specifically, the final #VAR line becomes (replacing %-1 with blah,)
#VAR out %concat( @out, %copy( blah,, @Count+1, 1))
As you can see, this leaves the second parameter (starting character) of %copy blank, uses @Count+1 for the third parameter (length) instead of 1, and has the 1 as an undefined (and ignored) fourth parameter. This is why you need to surround %-1 with quotes as Vijilante said.


LightBulb
Senior Member
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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