Push All Scripts
This commit is contained in:
3
StringSetCompare/StringSetCompare.sol
Normal file
3
StringSetCompare/StringSetCompare.sol
Normal file
@@ -0,0 +1,3 @@
|
||||
<Solution name="StringSetCompare">
|
||||
<Project name="StringSetCompare" path="StringSetCompare\StringSetCompare.prj" active="true"/>
|
||||
</Solution>
|
||||
113
StringSetCompare/StringSetCompare/Object/StringSetCompare_1.lsl
Normal file
113
StringSetCompare/StringSetCompare/Object/StringSetCompare_1.lsl
Normal file
@@ -0,0 +1,113 @@
|
||||
// :CATEGORY:Strings
|
||||
// :NAME:StringSetCompare
|
||||
// :AUTHOR:Encog Dod
|
||||
// :CREATED:2010-01-10 05:20:56.000
|
||||
// :EDITED:2013-09-18 15:39:05
|
||||
// :ID:842
|
||||
// :NUM:1170
|
||||
// :REV:1.0
|
||||
// :WORLD:Second Life
|
||||
// :DESCRIPTION:
|
||||
// StringSetCompare
|
||||
// :CODE:
|
||||
// From the book:
|
||||
//
|
||||
// Scripting Recipes for Second Life
|
||||
// by Jeff Heaton (Encog Dod in SL)
|
||||
// ISBN: 160439000X
|
||||
// Copyright 2007 by Heaton Research, Inc.
|
||||
//
|
||||
// This script may be freely copied and modified so long as this header
|
||||
// remains unmodified.
|
||||
//
|
||||
// For more information about this book visit the following web site:
|
||||
//
|
||||
// http://www.heatonresearch.com/articles/series/22/
|
||||
|
||||
string CHARS = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
|
||||
|
||||
integer compareLen(string a, string b,integer len)
|
||||
{
|
||||
integer result = 0;
|
||||
if(a != b)
|
||||
{
|
||||
integer index = 0;
|
||||
do
|
||||
{
|
||||
string chara = llGetSubString(a,index,index);
|
||||
string charb = llGetSubString(b,index,index);
|
||||
|
||||
integer posa = llSubStringIndex(CHARS ,chara);
|
||||
integer posb = llSubStringIndex(CHARS ,charb);
|
||||
|
||||
if((posa >= 0) && (posb >= 0))
|
||||
{
|
||||
result = posa - posb;
|
||||
}
|
||||
else if(posa >= 0)
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
else if(posb >= 0)
|
||||
{
|
||||
result = -1;
|
||||
}
|
||||
|
||||
if(result != 0) index = len;
|
||||
++index;
|
||||
|
||||
}
|
||||
while(index < len);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
integer compareNoCaseLen(string a, string b,integer len)
|
||||
{
|
||||
string stra = llToLower(a);
|
||||
string strb = llToLower(b);
|
||||
return compareLen(stra,strb,len);
|
||||
}
|
||||
|
||||
integer compare(string a, string b)
|
||||
{
|
||||
integer lena = llStringLength(a);
|
||||
integer lenb = llStringLength(b);
|
||||
integer result;
|
||||
if(lena < lenb)
|
||||
result = compareLen(a,b,lena);
|
||||
else
|
||||
result = compareLen(a,b,lenb);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
integer compareNoCase(string a, string b)
|
||||
{
|
||||
integer la = llStringLength(a);
|
||||
integer lb = llStringLength(b);
|
||||
string stra = llToLower(a);
|
||||
string strb = llToLower(b);
|
||||
integer result;
|
||||
if(la < lb)
|
||||
result = compareNoCaseLen(stra,strb,la);
|
||||
else
|
||||
result = compareNoCaseLen(stra,strb,lb);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Some test uses
|
||||
default
|
||||
{
|
||||
state_entry()
|
||||
{
|
||||
llSay(0, "compareNoCase(hello,HELLO): " + (string)compareNoCase("jeff","Jeff") );
|
||||
llSay(0, "compare(hello,HELLO): " + (string)compare("jeff","Jeff") );
|
||||
llSay(0, "compare(aaa,bbb): " + (string)compare("aaa","bbb") );
|
||||
llSay(0, "compare(aaa,bbb): " + (string)compare("bbb","aaa") );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
vti_encoding:SR|utf8-nl
|
||||
vti_timelastmodified:TR|08 Sep 2013 03:49:07 -0000
|
||||
vti_extenderversion:SR|12.0.0.6211
|
||||
vti_backlinkinfo:VX|
|
||||
vti_author:SR|alien\\fred
|
||||
vti_modifiedby:SR|alien\\fred
|
||||
vti_timecreated:TR|18 Sep 2013 20:39:05 -0000
|
||||
6
StringSetCompare/StringSetCompare/StringSetCompare.prj
Normal file
6
StringSetCompare/StringSetCompare/StringSetCompare.prj
Normal file
@@ -0,0 +1,6 @@
|
||||
<Project name="StringSetCompare" guid="D6A35B83-6C00-1014-B904-200204C60A89">
|
||||
<Object name="Object" guid="D6A35C66-6C00-1014-B904-200204C60A89">
|
||||
<Script name="StringSetCompare_1.lsl" guid="D6A3820B-6C00-1014-B904-200204C60A89">
|
||||
</Script>
|
||||
</Object>
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
vti_encoding:SR|utf8-nl
|
||||
vti_timelastmodified:TR|17 Aug 2013 23:32:26 -0000
|
||||
vti_extenderversion:SR|12.0.0.0
|
||||
vti_cacheddtm:TX|17 Aug 2013 23:32:26 -0000
|
||||
vti_filesize:IR|271
|
||||
vti_backlinkinfo:VX|
|
||||
6
StringSetCompare/_vti_cnf/StringSetCompare.sol
Normal file
6
StringSetCompare/_vti_cnf/StringSetCompare.sol
Normal file
@@ -0,0 +1,6 @@
|
||||
vti_encoding:SR|utf8-nl
|
||||
vti_timelastmodified:TR|17 Aug 2013 23:32:26 -0000
|
||||
vti_extenderversion:SR|12.0.0.0
|
||||
vti_cacheddtm:TX|17 Aug 2013 23:32:26 -0000
|
||||
vti_filesize:IR|144
|
||||
vti_backlinkinfo:VX|
|
||||
Reference in New Issue
Block a user