[Thread Prev] [Thread Next]
On 29 Jul 2007 at 14:45, Boyd, Ronald wrote:
> This is a project from one of my students from this past
> week. His page polygon-or-non was a bit of a stretch for
> the intention of the project and so went unfinished at the
> end of the week show. Our problem was in trying to write a
> procedure that would sense the heading of the turtle
> respond correclty to the users choice of polygon or non
> polygon. Luckily he choose to draw the non-polygon shapes
> next to each other which should have made it easier. Our
> first attempt is in the turtles note section. We tried
> having two buttons that would elicit either a correct or a
> incorrect response based on sensing if the turtles heading
> fell within a parameter using the ifelse.
the code was:
to non-polygon
jag,
ifelse {heading > 284 and heading < 85} [correct][wrong]
end
to polygonshape
jag,
ifelse {heading < 285 and heading > 85} [correct][wrong]
end
to correct
announce [correct]
end
to wrong
announce [Try again]
end
but "and" is like any other procedure in MicroWorlds
it receives two inputs, that should be truth values.
The right syntax is:
ifelse and (heading > 284) (heading < 85) [correct][wrong]
or simply
ifelse and heading > 284 heading < 85 [correct][wrong]
I've never seen curly brackets used in MicroWorlds:
Daniel
OpenWorld Learning
Previous by thread:
Heading issue
Next by thread:
RE: Heading issue
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.
|