MicroWorlds

A Conversation Program

MicroWorlds allows the user to interact with the program. A simple way to show this is using a conversation program. The following program uses the question command to display a question. The answer to the question is stored in answer which is then placed in the variable nam (short for name). The insert command inserts the phrase into an existing text box, print char 32 prints a space and print :nam then prints the name from answer. The next question and answer is followed by an ifelse command so that if the answer is greater than 5 it prints,"You are an old hand" otherwise it prints "Is that all".

Create a text box on the page and then enter the converse procedure written below in the procedures page. Add a button with the command converse and then test it.

to converse

ct
question[Hello this is MicroWorld's
What is your name?]
make "nam answer
insert [It is nice to meet you] print char 32 print :nam
wait 10
print "
question [Do you like music?]
ifelse answer = "yes [print [So do I]] [print [Pitty I do]]
wait 10
print "
question [How many years have you been using a computer?]
ifelse answer > 5 [print [You are an old hand]] [print [Is that all]]
wait 10
print "
insert [Catch you later] print char 32 print :nam
print [bye]

end

When it all works improve on the converse procedure by adding at least 3 more questions and answers.

You are now ready to move on to Using a Menu







Last Update: 22-Oct-2006
Copyright © 2000-06 Geoff Adcock