MantisBT - opensim
View Issue Details
0006597opensim[REGION] Script Functionspublic2013-04-06 03:062019-02-26 05:14
TBG Renfold 
 
nonefeaturealways
resolvedopen 
master (dev code) 
 
Standalone (1 Region) , Standalone (Multiple Regions) , Grid (1 Region per Sim) , Grid (Multiple Regions per Sim)
ODE
.NET / Windows32
None
Singularity 1.7.3 (3624)
0006597: [PATCH] - Adds osStringStartsWith and osStringEndsWith.
Allows scripters to check if a string starts or ends with specified text.

The functions are case sensitive (basically String.StartsWith/EndsWith).

Thought these would be helpful instead of comparing strings using llGetSubString = or != , which would possibly use llStringLength at some point as well.

Both functions return TRUE on match, otherwise FALSE.
osStringStartsWith("my string", "my"); << returns TRUE
osStringStartsWith("my string", "My"); << returns FALSE

osStringEndsWith("my string", "string"); << returns TRUE
osStringEndsWith("my string", "my "); << returns FALSE
No tags attached.
patch 0001-Added-osStringStartsWith-and-osStringEndsWith.patch (3,685) 2013-04-06 03:06
http://opensimulator.org/mantis/file_download.php?file_id=3519&type=bug
Issue History
2013-04-06 03:06TBG RenfoldNew Issue
2013-04-06 03:06TBG RenfoldFile Added: 0001-Added-osStringStartsWith-and-osStringEndsWith.patch
2013-04-06 03:06TBG RenfoldStatusnew => patch included
2013-04-10 14:33cmickeybNote Added: 0023776
2013-04-11 03:58TBG RenfoldNote Added: 0023777
2019-02-26 05:14TBG RenfoldNote Added: 0034857
2019-02-26 05:14TBG RenfoldStatuspatch included => resolved

Notes
(0023776)
cmickeyb   
2013-04-10 14:33   
do you have a couple test scripts to verify that this is working correctly?
(0023777)
TBG Renfold   
2013-04-11 03:58   
default
{
    state_entry()
    {

    }
    
    touch(integer t)
    {
        string TestString = "This string is checked at the start and end";
        
        //The following checks should return true.
        if (osStringStartsWith(TestString, "This")) // note, this is case sensitive
        {
            // This has returned true, so do something
            llOwnerSay("String starts with = true");
        }
        
        if (osStringEndsWith(TestString, "end")) // note, this is case sensitive
        {
            // This has returned true, so do something
            llOwnerSay("String ends with = true");
        }
        
        //The following checks should return false.
        if (osStringStartsWith(TestString, "is")) // note, this is case sensitive
        {
            // This has returned true, so do something
            llOwnerSay("String starts with = false");
        }
        
        if (osStringEndsWith(TestString, "and")) // note, this is case sensitive
        {
            // This has returned true, so do something
            llOwnerSay("String ends with = false");
        }
    }
}

I did do some tests on these functions, not tried them under loops/stress tests etc, but I would hope that they work correctly, after all, they are built in .net functions that have been wrapped and they haven't been adjusted in anyway internally.

I wont be able to try these functions out again at least until this weekend. Feedback would be helpful if anyone decided to try this patch out in the mean time.
(0034857)
TBG Renfold   
2019-02-26 05:14   
Marking resolved as it's 5 years old and UBit added similar features a few months back in commit 9dfb906666.