[MWForum]Testing for finish line

Susan Einhorn mwforum@lists.mathcats.com
Tue, 18 May 2004 12:35:37 -0400


Message
On 18 May 2004 at 9:36, Bob Irving wrote:

>Hi again,
>Another "should be easy one" -- using microworlds pro, and the student is
having a turtle >go along a straight course to a finish line. We want to
test for when the turtle has reached >or passed the finish line.
>Currently we have something like
>If t1's xcor > 304 [gameover]

Hi,

I saw your question and thought maybe I could help.

There are a couple of things to think about when using math operators such
as "=" or ">"

What Logo is reading/running first is the statement xcor > 304, which
outputs "true or "false (let's say "false for this example). Then it
reads/runs "if t1's false". False is not valid input for an ask command
(using the apostrophe with a turtle's name is the same as the ask command),
so you get an error message.

This may seem confusing, but it's all very logical. I kind of like it
because it forces me to look at what I wrote and think carefully about what
I'm saying and trying to do.

Also, you need to use either a quotation mark or square brackets around the
input to t1's.

So, you may want to try:
if 304 < t1's [xcor][gameover]

Hope this helps.

Susan Einhorn
LCSI