OpenSim.Region.ScriptEngine.Shared.Api.LSL_Api.llInsertString C# (CSharp) Method

llInsertString() public method

Insert string inserts the specified string identified by src at the index indicated by index. Index may be negative, in which case it is end-relative. The index may exceed either string bound, with the result being a concatenation.
public llInsertString ( string dest, int index, string src ) : OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString
dest string
index int
src string
return OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString
        public LSL_String llInsertString(string dest, int index, string src)
        {
            m_host.AddScriptLPS(1);

            // Normalize indices (if negative).
            // After normlaization they may still be
            // negative, but that is now relative to
            // the start, rather than the end, of the
            // sequence.
            if (index < 0)
            {
                index = dest.Length+index;

                // Negative now means it is less than the lower
                // bound of the string.

                if (index < 0)
                {
                    return src+dest;
                }

            }

            if (index >= dest.Length)
            {
                return dest+src;
            }

            // The index is in bounds.
            // In this case the index refers to the index that will
            // be assigned to the first character of the inserted string.
            // So unlike the other string operations, we do not add one
            // to get the correct string length.
            return dest.Substring(0,index)+src+dest.Substring(index);

        }
LSL_Api