Flyingroc Chung
:)
Join date: 3 Jun 2004
Posts: 329
|
07-08-2004 09:39
I want to compare 2 strings, and to my horror, LSL does not implement < or > for strings. I've come up with this: //returns 0 if a ==b; -1 if a < b; 1 is a > b integer compare_strings(string a, string b) { if(a == b) { return 0; } else { list x = llListSort([a,b], 1, TRUE); if(llList2String(x, 0) == a) { return -1; } else { return 1; } } }
Is there a "native" way of comparing strings? LSL can sort them so there is at least internally implemented a strign comparison routine.
|
Rhysling Greenacre
Registered User
Join date: 15 Nov 2003
Posts: 132
|
07-08-2004 09:51
In God's eyes all strings are equal!
|
Caoimhe Armitage
Script Witch
Join date: 7 Sep 2004
Posts: 117
|
11-03-2004 07:33
From: Flyingroc Chung I want to compare 2 strings, and to my horror, LSL does not implement < or > for strings. This is apalling. I have just hit this same problem myself. THanks for the code posting.
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
11-03-2004 07:57
something else you may want to keep in mind, force both strings to lower case to eliminate that possibility (unless you were LOOKING for case differences too)...
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|