Don't click here unless you want to be banned.
LSL Wiki :
llInsertString
HomePage
::
PageIndex
::
RecentChanges
::
RecentlyCommented
::
UserSettings
:: You are crawling22.us.archive.org
**##[[string]] llInsertString([[string]] dst, [[integer]] position, [[string]] src)##** Inserts **##src##** into **##dst##** at **##position##** and [[return returns]] the result. Unlike most other string/[[list]] functions, this one does not support using a negative position to count backwards from the end of the string. Example: %%(lsl) llInsertString("abcdef", 3, "123"); // returns "abc123def" %% '' ARGH!!! What an evil little ambiguity! I kept fussing with this function, trying to get it to count backwards... what a waste of time.'' ''Channeling this anger, I created this little code snippet that will provide the backwards counting: -Chris'' %%(lsl) string insertString(string destination, integer position, string str) { if (position < 0) position += llStringLength(destination) + 1; return llInsertString(destination, position, str); }%% Passing ##-1## as ##position## will provide the same functionality as appending ##str## to the end of ##destination## with the += operator. ''I don't think passing -1 should append to the end, if this behaivor is wanted a very big integer should be passed instead. Using -1 this way, makes negative indexes work differently with this function then the other LSL functions. Using large integers (like 0x7FFFFFFF) has not been shown to effect performance'' -[[BlindWanderer BW]] %%(lsl) string insertString(string destination, integer position, string str) { if (position < 0) position += llStringLength(destination); return llInsertString(destination, position, str); }%% str_replace by Chad Statosky - ''The list method can be nasty.'' str_replace entirely rewriten by [[BlindWanderer BW]] to be more robust. %%(lsl) string str_replace(string from, string to, string str) { integer e = llStringLength(from) - 1; if(e > -1) { string b = str; integer c = -1; integer f = llStringLength(to) - 1; @loop;//instead of a while loop, saves 5 bytes (and run faster). integer d = llSubStringIndex(b, from) + 1; if(d) { // c+=d; // str = llInsertString(llDeleteSubString(str,c,c+e), c, to); // c += f; // b = llGetSubString(str, c + 1, 0x4000); b = llGetSubString(str = llInsertString(llDeleteSubString(str,c+=d,c+e), c, to), (c += f) + 1, 0x4000); jump loop; } } return str; } %% ---- [[functions Functions]] | [[string String]]
Valid XHTML 1.0 Transitional
::
Valid CSS
:: Powered by
WakkaWiki 0.1.2