Creations Posts ID:172781
 ID:172781   Mar 28 2004, 1:37 am (Edited on Mar 28 2004, 1:43 am) Seemed simple at first, but I've tried many times to create a proc that would take a text string, flip it around (IE, "Hello BYOND!" would end up "!DNOYB olleH") and then display it however I choose, but I've failed miserably many times and my coding is so messed up that I'm not even gonna post it. Could anyone educate me on how to perform this?
Enigmaster2002 wrote:
Seemed simple at first, but I've tried many times to create a proc that would take a text string, flip it around (IE, "Hello BYOND!" would end up "!DNOYB olleH") and then display it however I choose, but I've failed miserably many times and my coding is so messed up that I'm not even gonna post it. Could anyone educate me on how to perform this?

I have just been toying around with this, and i havent really checked this, but this is what i came up with (i know its very unoptimised, but i just threw this together)
 ```mob/verb/switchtext(T as text) usr << T // outputting the message before-hand var/z[length(T)] // make a new list that is the length of the text var/c = 1 for(var/x = length(T), x > 0, x--) // populate the list backwards with the text message z[x] = copytext(T,c,c+1) c++ var/v for(var/x = 1, x < length(T)+1, x++) v += z[x] // a text string that has the original message backwards usr << v // output the final message to the verb user ```
 #2 Mar 28 2004, 2:49 am In response to Lazyboy (#1) Eeek. No need to use lists! =) A much simpler and faster version: proc/reversetext(txt as text) var/reversed="" for (var/X=length(txt); X>=1; X--) reversed+=copytext(txt,X,X+1) return reversed
 #3 Mar 28 2004, 2:53 am In response to Crispy (#2) Crispy wrote: Eeek. No need to use lists! =) Too much c++ for me i think. Plus its been a long day and i couldnt be bothered thinking too much.
 #4 Mar 28 2004, 3:20 am In response to Crispy (#2) Now, I hate to bother, but I see the code, I know it works, but I haven't the faintest idea why. Most specifically, that for() statement. Mind explaining it?