|
Wannabe Beginner
Joined: 13 Dec 2001 Posts: 10 Location: USA
|
Posted: Thu Dec 20, 2001 8:38 am
My string to array problem |
Ok... Here's a nice complicated one: I want to convirt each character in the string
SG~d@WEwuS]{z}lRD@ZXB_fr[ICWctJ
(or any other randomly generated 32 character string)
to an array, where each of the characters in the original string is a value in the array. Thank ye! |
|
|
|
Acaila Apprentice
Joined: 30 Aug 2001 Posts: 187 Location: Netherlands
|
Posted: Thu Dec 20, 2001 9:27 am |
As long as it's a randomly generated string, then what's the point in translating it into another string (which would be randomly messed up to then)?
If you just want to substitute each character in the string to a corresponding character in another string then that's pretty easy to set up. Just let me know if you want that.
Acaila |
|
|
|
Wannabe Beginner
Joined: 13 Dec 2001 Posts: 10 Location: USA
|
Posted: Thu Dec 20, 2001 5:30 pm |
My goal is to take each character in another string, and its corresponding character in this string, and perform some formulas on them, to make them into a third string.
|
|
|
|
Acaila Apprentice
Joined: 30 Aug 2001 Posts: 187 Location: Netherlands
|
Posted: Thu Dec 20, 2001 7:54 pm |
#VAR String1 {SG~d@WEwuS]{z}lRD@ZXB_fr[ICWctJ}
#VAR String2 {S=1|G=2|~=3, or whatever}
#LOOP %len(@String1) {Put the formulas here}
The value from the character corresponding to the first string in the second string can be found by %db(@String2, %i)
For example:
#LOOP %len(@String1) {#ADD Number %db(@String2, %i)}
This will loop through @String1 and for each character add the value from its corresponding character in @String2 to the variable @Number.
You can also replace each character in @String1 by the corresponding character in @String2:
#LOOP %len(@String1) {#VARIABLE String1 %replace( @String1, %copy( @String1, %i, 1), %copy( @String2, %i, 1))}
#FORALL can be used in almost the same things as #LOOP btw.
Since you said can have all sorts of special characters in those strings you also need to play a bit with %expand to keep zMUD from seeing them as special characters.
I hope all of this makes sense to you :)
Acaila |
|
|
|
Wannabe Beginner
Joined: 13 Dec 2001 Posts: 10 Location: USA
|
Posted: Thu Dec 20, 2001 11:41 pm |
Thanks for the help. I finnaly got it to work. Thanks again!
|
|
|
|
|
|