 |
dskorren Novice
Joined: 07 Feb 2002 Posts: 48 Location: Philippines
|
Posted: Sat Nov 16, 2002 12:15 pm
reverse string |
can somebody help me in making a string reversal alias? tried but failed miserably. thanks
|
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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 |
|
|
|
 |
dskorren Novice
Joined: 07 Feb 2002 Posts: 48 Location: Philippines
|
Posted: 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. 
|
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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 |
|
|
|
 |
Evangelist Adept
Joined: 10 Oct 2000 Posts: 224 Location: USA
|
Posted: 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 |
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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 |
|
|
|
 |
Evangelist Adept
Joined: 10 Oct 2000 Posts: 224 Location: USA
|
Posted: 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 |
|
|
|
 |
|
|
|