Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetASCII(string s)

Huns Valen
Don't PM me here.
Join date: 3 May 2003
Posts: 2,749
04-14-2004 05:46
Returns an integer containing the ASCII value of the first character of a string. Currently the only way to do this is with a lookup table.
Tiger Crossing
The Prim Maker
Join date: 18 Aug 2003
Posts: 1,560
04-14-2004 08:14
Or:

list llString2ASCII( string text )

Returns a list of integers, one for each character in the string.
_____________________
~ Tiger Crossing
~ (Nonsanity)
Oz Spade
ReadsNoPostLongerThanHand
Join date: 23 Sep 2003
Posts: 2,708
04-14-2004 23:40
I endorse this idea/feature.
_____________________
"Don't anticipate outcome," the man said. "Await the unfolding of events. Remain in the moment." - Konrad
Kex Godel
Master Slacker
Join date: 14 Nov 2003
Posts: 869
04-16-2004 12:39
http://www.badgeometry.com/wiki/ExampleNumberConversion

llAsciiToInteger() and llInteger2Ascii() would be nice though to save memory, and very useful given the the RPC capability which is soon coming.

My preferred prototype implementation for A2I conversion would be:

integer llAsciiToInteger(string s, integer index);

That way to get all of the characters, I would loop with:
CODE

list intList;
integer l = llStringLength(text);
integer i;
for(i=0;i<l;i++){
intList += llAsciiToInteger(text,i);
}


As to Tiger's suggestion to have this done built-in, I think that could be useful too, but with a more specific name, llAscii2IntegerList();

Actually I wonder what commonly needed functions could be made into built-in functions to save us all on memory.
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
04-19-2004 18:40
For one, id like a regular old llString2CharList(string s) function, that splits a multi-character string into one-character strings in a list with length == llStringLength(s).

This is a bottleneck in my parsing code, there's currently no way to split a string into its characters without needing to loop over each index in the string, and then llGetSubString each character. One word: SLOW.

llAscii2IntegerList(); would partially solve this problem, save that Id then have to loop over the returned list with llInteger2Ascii(). :sigh:

==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Kex Godel
Master Slacker
Join date: 14 Nov 2003
Posts: 869
04-20-2004 08:32
From: someone
Originally posted by Christopher Omega
For one, id like a regular old llString2CharList(string s) function, that splits a multi-character string into one-character strings in a list with length == llStringLength(s).

Keep in mind how much more memory a list of one-character strings will use versus a single string of all the characters. =)

I don't have the info in front of me, but last time I checked, each additional list element automatically uses at least 10 bytes of memory, regardless of the datatype.

Since it seems that LSL will probably never get arrays, maybe we could still adopt the C array syntax for the special purpose of randomly accessing characters in a string.

With all the coming I/O capabilities, we are going to need better string manipulation. So this, along with atoi and itoa conversions may become very handy, especially in the limited memory environment.
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
04-20-2004 15:04
From: someone
Originally posted by Kex Godel
Keep in mind how much more memory a list of one-character strings will use versus a single string of all the characters. =)


Heh, trust me, I do :p
However, Ive been using my self-rolled str2CharList() function with no memory problems whatsoever. :)

Its just slow :-/
==Chris