List Equality
|
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
|
11-30-2009 18:32
I'm hoping this is a quick-and-easy answer.
The following statement:
else if (CurrentUserInterfacePath == ["Home, Hardware"]) { [Blah blah blah] }
Is being triggered no matter what CurrentUserInterfacePath is. Yes, I've debugged it.
I haven't scripted in a while due to being busy IRL, so I'm guessing it's some obvious syntax error that I've overlooked.
Thanks in advance.
_____________________
Life is a highway... And I just missed my exit.
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
11-30-2009 19:07
Neither http://wiki.secondlife.com/wiki/List nor http://wiki.secondlife.com/wiki/LSL_Operators say anything about comparing lists using the "==" operator, but the List category page refers to the user function ListCompare (under the "Extended List Operations" heading) at http://wiki.secondlife.com/wiki/ListCompare, which looks like what you need. Incidentally, is it possible that your use of ["Home, Hardware"] is meant to refer to a two-element list? If so it should be written ["Home", "Hardware"].
|
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
|
11-30-2009 19:15
Thanks for the link, I'll check it out. From: Pete Olihenge Incidentally, is it possible that your use of ["Home, Hardware"] is meant to refer to a two-element list? If so it should be written ["Home", "Hardware"].
Yeah, that too. Although it doesn't look like that's the issue.
_____________________
Life is a highway... And I just missed my exit.
|
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
|
11-30-2009 19:21
Found this JIRA post: http://jira.secondlife.com/browse/SVC-113Looks like the == operator compares the LENGTH of lists, not the contents. I suppose I can just convert the list to a string and compare that way, but that seems a bit silly.
_____________________
Life is a highway... And I just missed my exit.
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
11-30-2009 19:36
That ties in with using (my_list != []) as a more efficient verson of llGetListLength. The ListCompare function looks pretty efficient and seems a far neater way to go than converting the lists to strings and then comparing those.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-30-2009 20:49
IIRC list find list will only support 8 elements in the find portion, check that first. if so you may need to loop it an account for the offset in that test.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
12-01-2009 00:31
There's no mention of an eight element limit in the wiki entries for llListFindList (the ll function at the heart of ListCompare) and the JIRA search links don't bring anything up.
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
12-01-2009 01:05
Might this user function in the wiki be what you need? http://wiki.secondlife.com/wiki/ListCompare
|
Indeterminate Schism
Registered User
Join date: 24 May 2008
Posts: 236
|
12-01-2009 02:46
Because list operations are so slow even those in ListCompare (eg; '(a = []) + a') might make it more efficient to test for llList2CSV(CurrentUserInterfacePath) == "Home, Hardware" although I agree that it seems a bit silly to have to go that way.
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
12-01-2009 03:28
Veering a bit off-topic here, but is there an easy way to compare the execution speed and memory usage of different segments of code?
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-01-2009 16:13
From: Pete Olihenge There's no mention of an eight element limit in the wiki entries for llListFindList (the ll function at the heart of ListCompare) and the JIRA search links don't bring anything up. I may have misremembered the specific function, or it just may not be mentioned. that's why I suggested testing to be sure first. (Portal is mostly written by us, and then mostly by strife I think, who, while talented and prolific, can't catch everything) From: Pete Olihenge Veering a bit off-topic here, but is there an easy way to compare the execution speed and memory usage of different segments of code? yes this one tests memory size http://wiki.secondlife.com/wiki/User:Void_Singer/Challenge#Function_Size_Test_Scriptand this one tests function speed  (this is almost useless for testing small code segments in mono, probably because of the way execution frames are built in mono) I had a conglomerate script that would test both together, but I seem to have lost it.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
|
12-02-2009 02:02
Thanks void, those links will be very useful.
|
Indeterminate Schism
Registered User
Join date: 24 May 2008
Posts: 236
|
12-02-2009 04:32
Caveats for llParseList2String() include this "Only the first 8 separators and first 8 spacers that you specify will be used. Any beyond that will be ignored". Is that what you were thinking of Void? (I've got no idea if it applies to llListFindList() as well)
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-02-2009 16:14
From: Indeterminate Schism Caveats for llParseList2String() include this "Only the first 8 separators and first 8 spacers that you specify will be used. Any beyond that will be ignored". Is that what you were thinking of Void? (I've got no idea if it applies to llListFindList() as well) that may be (isn't fuzzy memory fun... not) I did write some multi/reverse find functions with both....
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|