Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

strange loop counter behavior ... bug?

Web Page
slow but steady
Join date: 4 Dec 2004
Posts: 129
08-25-2005 11:03
I am converting a list of keys to names (strings)

This works:
integer t=0;
integer i=0;
for (i=0;i<llGetListLength(GL);i++);
{
temp=llKey2Name(llList2Key(GL,t));
GNL=llListInsertList(GNL,[temp],t);
t++;
}

This doesn't:
integer i=0;
for (i=0;i<llGetListLength(GL);i++);
{
temp=llKey2Name(llList2Key(GL,i));
GNL=llListInsertList(GNL,[temp],i);
}

This doesn't:
integer t=0;
while (t<llGetListLength(GL));
{
temp=llKey2Name(llList2Key(GL,t));
GNL=llListInsertList(GNL,[temp],t);
t++;
}

Huh? Apparently i is counting but not allowed to be used within the for loop

I have not taken the stability dl nor have I ever seen behavior like this before.
Is it becasue there is only one element (at index 0) in the GL list?
Still shouldn't be happening ... ever ... afaik
Minsk Oud
Registered User
Join date: 12 Jul 2005
Posts: 85
08-25-2005 11:40
<edit>Yup, I'm asleep. Thanks Jillian *smacks self*. For whatever reason I read to OP as regarding a compile error.</edit>

Works as expected in Second Life 1.6.11 (3) Aug 22 2005 09:08:16. Don't suppose you could paste the entirety of a script that exhibits the behavior? If it is some archacic bug, I rather suspect it will be triggered by the earlier declarations. I just tried:

CODE
default
{
touch_start(integer total_number)
{
list GL = [ 1, 2, 3, 4, 5];
list GNL;
string temp;
integer i=0;
for (i=0;i<llGetListLength(GL);i++);
{
temp=llKey2Name(llList2Key(GL,i));
GNL=llListInsertList(GNL,[temp],i);
}
llOwnerSay((string)i);
llOwnerSay((string)GL);
llOwnerSay((string)GNL);
}
}
_____________________
Ignorance is fleeting, but stupidity is forever. Ego, similar.
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
08-25-2005 11:44
That first ; after the for() should not be there:
CODE
integer i=0;
for (i=0;i<llGetListLength(GL);i++)
{
temp=llKey2Name(llList2Key(GL,i));
GNL=llListInsertList(GNL,[temp],i);
}
_____________________