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
dskorren
Novice


Joined: 07 Feb 2002
Posts: 48
Location: Philippines

PostPosted: Sat Nov 16, 2002 12:15 pm   

reverse string
 
can somebody help me in making a string reversal alias? tried but failed miserably. thanks
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Nov 16, 2002 2:11 pm   
 
#VAR reverse {};#LOOP 1,%len(@string) {#VAR reverse {@{reverse}%copy({@string}, %len(@string) + 1 - %i, 1)}}

I don't expect this to handle special characters.

LightBulb
Senior Member
Reply with quote
dskorren
Novice


Joined: 07 Feb 2002
Posts: 48
Location: Philippines

PostPosted: Sun Nov 17, 2002 12:24 pm   
 
Thank you again LightBulb, if you have time can you explain a bit since i really am lost on that alias you made. If i understood it then i would be able to handle other string manipulations.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Nov 17, 2002 1:02 pm   
 
I didn't make an alias, there's no #AL anywhere in it. It's just a routine. Here's an alias
#AL {#VAR reverse {};#LOOP 1,%len(%-1) {#VAR reverse {@{reverse}%copy({%-1}, %len(%-1) + 1 - %i, 1)}}}

As for understanding it, it's pretty obvious. Create an empty variable. Put the last character of the string in it. Add the next-to-last character. Add the character before that. And then the one before that, and so forth until all the characters have been added.


LightBulb
Senior Member
Reply with quote
Evangelist
Adept


Joined: 10 Oct 2000
Posts: 224
Location: USA

PostPosted: Fri Nov 22, 2002 5:56 pm   
 
This may be a no brainer, but if it's an empty alias, how would you call it?

Evangelist/Pernius
www.phidar.com/phidar.html
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Nov 22, 2002 8:03 pm   
 
You'd think nobody had ever seen a typo.
#AL AnyNameYouWantToGiveIt {#VAR reverse {};#LOOP 1,%len(%-1) {#VAR reverse {@{reverse}%copy({%-1}, %len(%-1) + 1 - %i, 1)}}}

LightBulb
Senior Member
Reply with quote
Evangelist
Adept


Joined: 10 Oct 2000
Posts: 224
Location: USA

PostPosted: Sat Nov 23, 2002 12:19 am   
 
Wasn't trying to make fun, but considered using the alias. For some reason I didn't notice that it didn't have a name. You do great work though lightbulb, alot of your solutions have helped me (the ones that havent...well, I wasn't having a problem that needed fixing :) all the others have worked though) Sorry if I came off as a smartass.

Evangelist/Pernius
www.phidar.com/phidar.html
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