Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llStringTrim() function!

Nargus Asturias
Registered User
Join date: 16 Sep 2005
Posts: 499
11-14-2005 02:52
I noticed one important function is missing from string library... the llStringTrim()!

This function should get rid of space leading and trailing a string. It shouldn't be hard to implement (since most computing language has it) and shouldn't be too slow either (just check the leading chars and skipped to the last char)

It might be very useful for commands and scripting stuffs, I believe.
Alexis Ingersoll
Registered User
Join date: 26 Jan 2005
Posts: 14
11-14-2005 03:54
It's a nice suggestion. I guess it raises the larger question of how minimal the Lindens want to keep the library. Do they want to stick as close to the fundamental functions as possible or would they rather add lots of convenience routines? The library so far *seems* to go with the former philosophy, but it's best for the Lindens to say.

In particular, you can easily make the trim function yourself out of the existing functions. The same goes for most of the other "missing" string functions found in a full-blown string library, e.g. replace, equalsIgnoreCase, etc. It *seems* like it should be easy to add those functions into the library, but maybe they have reasons for not wishing to clutter things up.

It certainly would be convenient to have it in the standard library, I totally agree. But if one scripts for long enough, it's inevitable to have to build up one's own library of functions anyways.

I'd be interested in feedback from the Lindens on their general stance about adding new functions. It would help a lot in gauging for ourselves what are appropriate suggestions.
Neil Protagonist
FX Monkey
Join date: 11 Jul 2003
Posts: 346
11-15-2005 00:33
Better string functions in general would be fantastic.
_____________________
"Control the things you can control, maggot. Let everything else take a flying f**k at you, and if you must go down, go down with your guns blazing." -Cort

Need fire? Visit my FX Store in Bisque(232, 48)
Sick-N-Wrong

Like Anime? Visit Nakama!
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
11-15-2005 13:11
string llStringTrim(string data, integer mask)

mask, these flags can be or'ed (though using 8 with anything else is useless.
CODE

TRIM_FRONT = 1 removes all spaces from the front of the string
TRIM_END = 2 removes all spaces from the end of the string
TRIM_DUPLICATE = 4 replaces 2 or more consecuative spaces with one space
TRIM_REMOVE = 8 remove all spaces from the string.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Alexandra Reisman
Registered User
Join date: 19 May 2006
Posts: 1
05-23-2006 09:23
I've just started playing SL and found that the trim function is mssing.
Yes, this could be done using a for loop, an if statment and a couple of substring commands, but I dont think this is really a good way of doing it as it will create many new string objects, using up memory.

I also think there should be more string functions available