[Thread Prev] [Thread Next]
Hi,
LOOP creates a parallel process. In fact, the way your START procedure is
organized, it runs LOWER, it launches the LOOP and it runs RAISE without
waiting.
So LOOP creates a parallel process and launches it... Being parallel, the
interpreter then immediately to the next instruction. That's not what you
want. The "recursive" approach below is different. The recursive procedure
(CHECKTEMP) spins on itself until the condition is met. When that happens,
this recursion is "killed" and the interpreter goes to the next line.
Try it out.
I'm not sure I understand what you want to do, but this MAY be the naswer.
In theory, the RCX does NOT support recursion but MW "plays a trick" and
makes it work. It uses the RCX firmware in a fancy way and makes it do
things it was not meant to...
to start
LOWER
CHECKTEMP
RAISE
end
to SENDINFO
sendmessage temp1
wait 10
end
to CHECKTEMP
if temp1 > 310 [stop]
SENDINFO
CHECKTEMP
end
-----Original Message-----
From: mwforum-admin@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
[mailto:mwforum-admin@xxxxxxxxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Erik
Nauman
Sent: Monday, April 07, 2008 12:56 PM
To: mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: ack! oops again-- RCX program quesiton
Sorry again, I'll be very careful not to hit ctrl + enter again in
mid-post...
Maybe there's a better forum for this, but I have a question about using the
loop command.
I'm trying to get the looping part of this RCX program to stop looping and
go on to the next part of the procedure if the temperature reaches a certain
value. If I put the final, raising procedure in place of [stop] it works but
it loops the raising procedure and I don't want that part looping. How do I
get out of the loop?
to start
procedure to lower the thermometer
loop [if temp1 > 310 [stop]
temperature]
procedure to raise thermometer
end
to temperature
sendmessage temp1
wait 10
end
Thanks,
Erik Nauman
The Hewitt School
Previous by thread:
ack! oops again-- RCX program quesiton
Next by thread:
RE: ack! oops again-- RCX program quesiton
To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.
|