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
shazara
Beginner


Joined: 17 Feb 2003
Posts: 16
Location: USA

PostPosted: Sun Mar 26, 2006 6:11 am   

Removing last character from a string
 
If I have "myvar" as a string of variable length, how would I delete the very last character of the string?
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Mar 26, 2006 6:38 am   
 
I believe this should do it however zmud is not open in front of me to check

myvar=%leftback(@myvar,1)

For more advanced control read up on
%copy, %len

[Edit: Realy it should work now]
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
shazara
Beginner


Joined: 17 Feb 2003
Posts: 16
Location: USA

PostPosted: Sun Mar 26, 2006 6:50 am   Solution?
 
Well, it does return the last character, but I couldn't see how it helped me delete that character, since it's not unique and the string has a changing length. This is what I ended up doing...let me know if there's a better way?

#LOOP 1,(%len(@myvar)-1) {#VAR myvar2 {@{myvar2}%copy({@myvar}, %i, 1)}}
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Mar 26, 2006 10:48 am   
 
According the help file %leftback should work, i also went in and tested and %leftback works and is alot quicker then trying to use a loop


myvar="A String"
myvar=%leftback(@myvar,1)

#SHOW @myvar
A Strin
_________________
Zmud Support Library
Zmud Knowledge Base
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