In the Source window you can enter and edit the text of your program. Only when the Source window is active is the File and Edit menu usable for editing purposes.
Make the Source window active. Look at the File submenu.
Now make Karel's World active. Again look at the File submenu. Notice the differences.
Back to: Top of this page |
When the World window is active:
Starting with a new Karel's World, create the following world using the techniques described above.
Now remove some of the walls to create the following world.
Select Edit Beepers... from the World menu. A dialog box appears as follows:
This dialog window shows the number of beepers (initially set to 0) at each intersection in Karel's World.
In the Beeper Dialog window, select the intersections and change the zero values to one to create the following world:
Notice the value assigned to an intersection must be a nonnegative integer. The user will be notified if an entry is made that is syntactically incorrect.
Karel can be initialized. The user can choose Karel's starting position in the world. The user can also choose which direction (North, East, South, or West) Karel is facing. Karel also has a beeper bag in which Karel carries the beepers that have been initially stored in Karel's bag or are added when Karel picks up beepers in Karel's World.
Select Edit Karel... from the World menu. A dialog box appears as follows:
Change Karel's position and direction to the following:
Back to: Top of this page |
Activate the Karel program. Next, activate the source window. Choose Open Source ... from the File menu. Find and open the Karel folder in the dialog box that appears. Choose the file Clean the Stairs and open it.
Next, activate the world window. Choose Open World ... from the File menu. Find and open the Karel folder in the dialog box that appears. Choose the file Cluttered Stairs and open it.
Run the program by choosing Run from the Run menu.
During execution, the current executing command is highlighted in the Source window. In the World window, the following controls appear:
The user may suspend or teminate execution by selecting the Pause or Stop button, respectively. When execution is suspended, the Pause button changes to read Resume. The speed of execution may be altered by repositioning the slide control.
Now it is time to play with the controls. Try to slow the execution. Try to pause and then resume. Rerun the program by first choosing Restore World from the World menu. Next choose Run from the Run menu. If you wish to run the program again, first restore Karel's World by choosing Restore World from the World menu. To activate the controls, the user must click on the controls when they appear.
The user can also execute one command at a time by choosing Single-Step from the Run menu. This option is very useful when you are writing your own program and are in the process of debugging it.
Restore Karel's World. Next choose Single-Step from the Run menu. Note the user needs to choose this option each time to see the continuation of the execution. The user may always choose Run to speed things up.
The first time the user executes the program, or executes the program after changes have been made to the code in the Source window, the syntax is checked first. The user can also check the syntax anytime by first making the Source window active and then choosing Check Syntax from the Run menu. When the syntax is being checked the following box appears:
Checking halts when the first syntax error is detected, with an error message. The offending term is highlighted.
Activate the Source window. Deliberately, misspell the word "climb" somewhere in the program. Next, choose Check Syntax from the Run menu. What happens? Now, fix the mistake and check the syntax again.
Next Topic: Karel's Language |
|