Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Object loop question

20 views
Skip to first unread message

Gadget

unread,
Dec 9, 2000, 6:03:36 PM12/9/00
to
Why do I get this message when the game is running:

[** Programming error: objectloop broken because the object remote
control unit was moved while the loop passed through it **]

with this code:

objectloop(i in player)
{move i to bookcase;}

?????


--
"So... you've compiled your own Kernel... Your skills are now complete..."
-----------------
It's a bird
It's a plane
No it's... Gadget?

Village Magazine: http://www.villagemagazine.nl
To send E-mail: remove SPAMBLOCK from adress.

Adam Biltcliffe

unread,
Dec 9, 2000, 6:50:33 PM12/9/00
to
Gadget <gad...@SPAMBLOCKhaha.demon.nl> wrote:

> Why do I get this message when the game is running:
>
> [** Programming error: objectloop broken because the object remote
> control unit was moved while the loop passed through it **]
>
> with this code:
>
> objectloop(i in player)
> {move i to bookcase;}
>
> ?????

I'm pretty sure the DM covers this, but just in case it doesn't:

Objectloops of the form objectloop(x in y) use the object tree to loop
over objects. In other words, it's equivalent to doing:

x = child(y);
while (x)
{
! do stuff
x = sibling(x);
}

As you can see, this will break if the code inside the objectloop moves
the object in question. Something along the way realises this and spouts
out an error.

The most efficient way to do what you want to do is like this:

while (child(player))
{
move child(player) to bookcase;
}

A more general but less fast approach is to use

objectloop (x)
{
if (x in player) move x to bookcase;
}

IIRC, this sort of objectloop doesn't use the object tree and so won't
break. Someone please shout at me in a nice way if I'm wrong.


HTH, jw


Gadget

unread,
Dec 9, 2000, 7:36:02 PM12/9/00
to
On Sat, 9 Dec 2000 23:50:33 -0000, "Adam Biltcliffe"
<abilt...@bigfoot.NOHORMELPRODUCTS.com> made the world a better
place by saying:

>Gadget <gad...@SPAMBLOCKhaha.demon.nl> wrote:
>
>> Why do I get this message when the game is running:
>>
>> [** Programming error: objectloop broken because the object remote
>> control unit was moved while the loop passed through it **]
>>
>> with this code:
>>
>> objectloop(i in player)
>> {move i to bookcase;}
>>
>> ?????
>
>I'm pretty sure the DM covers this, but just in case it doesn't:

It doesn't. It mentions the Objectloop in the beginning of the manual
but it doesn't explain these kind of things.

>Objectloops of the form objectloop(x in y) use the object tree to loop
>over objects. In other words, it's equivalent to doing:
>
>x = child(y);
>while (x)
>{
> ! do stuff
> x = sibling(x);
>}
>
>As you can see, this will break if the code inside the objectloop moves
>the object in question. Something along the way realises this and spouts
>out an error.
>
>The most efficient way to do what you want to do is like this:
>
>while (child(player))
>{
> move child(player) to bookcase;
>}
>
>A more general but less fast approach is to use
>
>objectloop (x)
>{
> if (x in player) move x to bookcase;
>}
>
>IIRC, this sort of objectloop doesn't use the object tree and so won't
>break. Someone please shout at me in a nice way if I'm wrong.
>
>
>HTH, jw
>

Thanks. The while-loop does the trick just as I wanted. And thanks for
explaining why my version did not work.

Joe Mason

unread,
Dec 9, 2000, 10:11:55 PM12/9/00
to
In article <3a3acea5...@news.demon.nl>, Gadget wrote:
>>I'm pretty sure the DM covers this, but just in case it doesn't:
>
>It doesn't. It mentions the Objectloop in the beginning of the manual
>but it doesn't explain these kind of things.

Yeah, there was a warning in an older version but it seems to have vanished.

Joe

Lucian Paul Smith

unread,
Dec 10, 2000, 2:04:24 AM12/10/00
to
Joe Mason (jcm...@uwaterloo.ca) wrote:

The info is presumably in DM4 (grr), though it can be found at gmd
currently at:

ftp://ftp.gmd.de/if-archive/programming/inform6/manuals/dm_supplement.txt

-Lucian

Mark Musante - Sun Microsystems

unread,
Dec 11, 2000, 10:03:31 AM12/11/00
to
Gadget (gad...@SPAMBLOCKhaha.demon.nl) wrote:
> Why do I get this message when the game is running:
>
> [** Programming error: objectloop broken because the object remote
> control unit was moved while the loop passed through it **]
>
> with this code:
>
> objectloop(i in player)
> {move i to bookcase;}
>
> ?????

And thus another IF year is born. Happy new year, everyone!


-=- Mark -=-

Gadget

unread,
Dec 11, 2000, 10:38:40 AM12/11/00
to
On 11 Dec 2000 15:03:31 GMT, mmus...@Sun.COM (Mark Musante - Sun
Microsystems) made the world a better place by saying:

eh????????????

Andrew MacKinnon

unread,
Dec 11, 2000, 3:10:00 PM12/11/00
to
Gadget (gad...@SPAMBLOCKhaha.demon.nl) wrote:
> Why do I get this message when the game is running:
>
> [** Programming error: objectloop broken because the object remote
> control unit was moved while the loop passed through it **]
>
> with this code:
>
> objectloop(i in player)
> {move i to bookcase;}

Try this:

objectloop(i)
{if (i in player) move i to bookcase;
}

I think there's some sort of optimization when you use a condition in
objectloop.

--
Andrew MacKinnon
andrew_mac...@yahoo.com
http://www.geocities.com/andrew_mackinnon_2000/

John Bytheway

unread,
Dec 11, 2000, 3:27:03 PM12/11/00
to
> >> [** Programming error: objectloop broken because the object remote
> >> control unit was moved while the loop passed through it **]
> >>
> >> with this code:
> >>
> >> objectloop(i in player)
> >> {move i to bookcase;}
> >>
> >> ?????
> >
> >And thus another IF year is born. Happy new year, everyone!
> >
> eh????????????

It is an odd comment - this question has been asked twice in the few months
I've been listening, it must give very short IF years (So! the six-monthly
comps _are_ annual, the best of both sides, right?).

John


Gadget

unread,
Dec 11, 2000, 5:34:24 PM12/11/00
to
On Mon, 11 Dec 2000 20:27:03 -0000, "John Bytheway"
<john.b...@btinternet.com> made the world a better place by
saying:

>> >> [** Programming error: objectloop broken because the object remote

LOL!

Erm, but if I follow your logic, the current comp is only once every
*two* if years. So we should now have *four* to get two every IF year.

0 new messages