7 Distant running commandsWe already know how to send and receive the messages. So far we were sending only simple messages, which we printed to the text screen or the turtle printed them to the graphic screen. In this chapter we will learn how to send the messages, which the turtle or Imagine can run. 1. Connect two or more Imagines (either locally or through the Internet). If we know, that other participants will send only instructions for the turtle, we can progress in next steps. 2. Specify the onReceive event as t1'run message in Change net1
dialogue box in all Imagines 3. Now, we can write in command line instructions, which the turtle can run, for example in one Imagine ? net1'send [][setPc "red setPw 4 repeat 4 [fd 50 rt
90]] in other Imagine ? net1'send [][setPw 3] If we do not know, what kind of messages other participant will send, we can specify the onReceive event as run message or we must progress in next steps. Note: This setting allows other users to send instructions, which can erase your object, procedures, files… 4. Check the RunEnabled setting in Change net1 dialogue box in all
Imagines
5. Now, we can type in command line instructions with list of instructions, for example: ? net1'sendRun [][new "Turtle [name myTurtle pos [-100
-50]]] We can use both send and sendRun commands. 6. Specify the onReceive event for net1 object as:
Then set the turtle (position, pen - pu, colour, width…). 7. Type in command line for example next instructions: ? net1'send [][This is a square.] ConclusionWe learned how to send messages, which Imagine or turtle in other Imagine can run. We must correctly set onReceive event and then use send command. This way we can send instruction for one object, which defined our participant. Or we must set RunEnabled setting on true and then use sendRun command. Imagine of other participant runs sent commands automatically. |