Individual String Character Access
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/02/2011 at 15:30, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Mac OSX ;
Language(s) : C.O.F.F.E.E ; XPRESSO ;---------
Hi guys!So I'm not a coder, really at all, but I'm trying to learn some basics. Right now I'm working on a COFFEE node in xpresso, and I'm attempting to get it to read a user generated string variable, then output an individual character, so if the use string was "Hello", I'd want to run it through the COFFEE node and return "H".
http://s150.photobucket.com/albums/s94/EitriTheBerserk/?action=view¤t=Picture142.png
This is where I'm at. I've been looking at the documentation for COFFEE and it said to access individual characters of a string, I can use [0] to access the array index number. When I do it in this case, it doesn't return an H, but "72" into the console. Is there something I'm missing, or is this typical? I tested it with numbers 0-4 in the brackets, each one returned a different value, save for 2 and 3, which both are L's. If I don't try to access a specific character from the string, it passes right through the node as expected, but individual characters are throwing me off.
Thanks in advance!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/02/2011 at 03:24, xxxxxxxx wrote:
The println() function is printing the ASCII value of the character. Uppercase H = ASCII 72, so that's what you get.
To print the actual character, do this:
println(tostring(Input1[0], "c"));