Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Remove a string from a list

Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
06-20-2009 19:00
well, I build a list from inventory items and I want to exclude one item (the script itself). Though I did it before but can't remember now, can anybody help me ?
Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
06-20-2009 19:34
solved , I remembered :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-21-2009 00:27
for those that don't remember...

CODE

list vLstInventory;
string vStrGrab;
string vStrIgnore = llGetScriptName();
integer vIntCount = llGetInventoryNumber( INVENTORY_ALL );

while (vIntCount){
vStrGrab = llGetInventoryName( --vIntCount );
if (vStrGrab != vStrIgnore){
vLstInventoy += (list)vStrGrab;
}
}


or for less processing on a single name (misses duplicates)

CODE

list vLstInventory;
string vStrGrab;
integer vIntCount = llGetInventoryNumber( INVENTORY_ALL );

while (vIntCount){
vLstInventoy += (list)vStrGrab;
}

integer vIntIgnore = llListFindList( vLstInventory, (list)llGetScriptName() );
vLstinventoryllList = llListRemove( vLstInventory, vIntIgnore, vIntIgnore );
_____________________
|
| . "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...
| -
Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
06-21-2009 15:33
Thanks Void, this method is more proper than mine.