Introduction

Program xKarel can occur as a game or as a simple programming language. Program xKarel is definitely great tool how to learn structure programming especially for children. Condition for working with this program is only to can read and write. Creating new procedures force user to algorithmization of the problem and to split the problem to the smaller parts. Program Karel was very popular in our country in the time of 8-bits computers.

What is the matter?

Karel is a robot. He can move on the resizable room. Karel know elementary commands as a command for move, turn to left, put a brick on the floor or take a brick from the floor. Karel can learn new commands from user. User programming new commands as a combination of known commands. Program for robot Karel is controled by syntax rules which are descripted in help. xKarel was original written as a semestral work on university ( VSB - TU OSTRAVA, Faculty of Electrical Engineering and Informatics , Department of Computer Science, Subject "Object oriented programming").

xKarel download and installation

You can obtain xKarel for free on address xKarel.sourceforge.net. xKarel is distributed under GPL license. You can download here a binary version for Microsoft® Windows® or Linux. You can download here a source code of xKarel that you can compile when you use other platform.

Menu

We describe separate items from menu in this chapter. Main menu:

Description of item

New

Create a new catalogue of commands. Delete all user defined commands.

Open...

Load a new catalogue of commands from a file. This choice show standard file window. The catalogue of commands for robot Karel has extension "krl".If you open a new catalogue every user defined commands are delete. If you don't want to delete all commands use a choice Add.

Add...

Load a catalogue of commands from a file. This choice show standard file window. The catalogue of commands for robot Karel has extension "krl". If you add commands from file user defined commands that exist in the actual catalogue will not be deleted. If you want delete old commands use a choiceOpen. If the actual catalogue have same command names as in the catalog that you can add they will be delete and replace with commands in the file.

Save

Save the actual catalogue to the file.

Save as...

Save the actual catalogue to the file and ask for name of the file.

Exit

Finish the program xKarel.

Run

Execute a command. If some command is partially executed (when debbuging) Karel will continue with executing of the command. If no command is partially executed then execution of selected command start from the begining.

Step

Next command in the debugged command is executed. (debugging)

Detail step

Start debugging next command in the debugged command. (debugging)

Stop

Stop execution of the command.

Reset

Stop execution of the command. All bricks are deleted and Karel is moved to the initial position. If any command was debugged the debugging is stopped.

New command

Add a new command. The edit window for new command is displayed. Detail description is in the chapter Step by step.

Edit

Modify a selected command.(Step by step)

Delete

Delete a selected command.(Window)

Random arrange bricks

Random arrange bricks in the room. It's usefull to test a new procedure.

Hide elements

If this choice is set then elementary commands are not displayed in the list of commands. You can choose what you prefer.

Room...

Enable you to set a size of the room. In this dialog you can set a density at the random arrange of the bricks. If the density is 0% than no bricks are placed at the random arrange of bricks. If the density is 100% than bricks are placed on the whole room. You can set here maximal count of bricks on the one square too.

Language

Choose a language for your source code. You can choose a different language source code and environment. Name of the elementary command will be in the choosed language.

Load setting

Restore saved setting of the program.

Save setting

Save actual setting of the program to a file. In Unix like systems create a .xkarelrc file in the home directory. In MS Windows create a xkarel.cfg file in the program directory.

Default setting

Set a default setting of the xKarel.

Syntax

Display a help to the syntax for the robot Karel.

Program

Display this help.

About program

Display an information about program xKarel and its authors.

Windows of the program

When xKarel starts two windows are displayed. Window "Catalogue" and "Room".

Window "Catalogue"

Catalogue window with description

Window "Room"

3D room window

Window "Room" (classic version)

2D room window

Program buttons

"Catalogue" window has 11 buttons. Buttons are used for quick work with program. Sense of all buttons are same as a choises from the menu. Sense of the buttons:

LEFT ORDER IMAGE EQUIVALENT CHOICE FROM MENU
1 New document File / New
2 Load a document from the disk device File / Open
3 Save a document to the disk device File / Save
4 Flash Command / Run
5 Arrow with an upper curve Command / Step
6 Arrow with a lower curve Command / Detail step
7 Circle with character s (nearly traffic sign stop) Command / Stop
8 Wire pull out from the socket Command / Reset
9 Wall from the bricks Room / Random arrange bricks
10 New command Command / New command
11 Command Command / Edit

Using this buttons speed up work with Karel. You don't must hardly search choises from the menu. You can only click on the picture. Next speed up of work are shortcut buttons.

Menu from edit window

If you choose from main menu choice Command / New command or Command / Edit an edit window will be showed. In this chapter is described something about choices from the menu.

Description of choices from the menu

Make

Create a new procedure (or actualize) in the catalogue and don't close the window. If you have an error in source code you are warned.

Close

Finish an editation. Create a new (or actualize) procedure in the catalogue. You will be invite to confirm an actualization. If you confirm an actualization program check the source code for errors.

Cut

Cut a selected text. Selected text is insert to the buffer. You can later put text back from the buffer.

Copy

Copy selected text to the buffer. You can later put text back from the buffer.

Put

Insert a text from the buffer.

Select all

Select all text in the window. Selected text can be cutted or copyed later.

Shortcut buttons

Shortcut button is button or combination of more buttons on the keyboard. When a shortcut button is pressed an action is called. Shortcut buttons:

KEY EQUIVALENT CHOICE FROM MENU
F1 Help / Syntax
F2 File / Save
F3 File / Open
F4 Command / Random arrange bricks
F5 Command / New command
F6 Command / Edit
F7 Command / Detail step
F8 Command / Step
F9 Command / Run
F10 Command / Reset
ESC Command / Stop

Step by step

In this chapter is described step by step how to create a new command and how to run it.

  1. Choose a menu choice Command / New command. Edit window will be displayed. Fill a text in window as showed on the picture. In edit window menu choose a choice Command / Close. Before you create your own command first study a syntax for the robot Karel.
    Edit window
    You will be asked if you want to actualize a procedure. If you choose Cancel, window is not closed and you can continue with editing a command. If you choose Yes a new command will be create. If an error is occured in source code you are invited. If you choose No command is not create.
  2. Debug and run this command. Set cursor on the command "TurnRound" in the list of commands. (Click on this command.) If you did the first step right the command is there. Now you choose a choice Command / Run in the menu. Karel turns round in the room. Stay with cursor on command "TurnRound" and 3x choose choice Command / Detail step. Watch what Karel will be doing in the room. Near description is in the chapter about debugging.

    I recommend you to create next procedure:

    Procedure TurnRight
    {
    # Command will turn Karel to right
      TurnRound
      TurnLeft
    }
    

    This procedure will be usefull in the next chapter. You can run or "stepping" this procedure again.

  3. New command in the catalogue save to the disk file. If you don't do it you will not have this commands in catalogue on next run of the xKarel. For save a catalogue choose a choice File / Save. After next xKarel run choose a choice File / Open... or File / Add for read a catalogue from a disk file. Any time you appear work with menu tedious you can use buttons or shortcut buttons for speed up work.

NOTE:Try to intend why wasn't better define first the procedure "TurnRight" with commands "TurnLeft" and then the procedure "TurnRound" with commands "TurnRight".

Debugging

Debugging is searching errors in procedures (commands) with gradual steping this commands. How to perform stepping and what is difference between "Step" and "Detail step" is explained on commands "TurnRound" and "TurnRight" from previous chapter. Set a cursor in list to command "TurnRight" and choose Command / Detail step or Command / Step in the menu. (You can use Buttons or Shortcut keys too.) It is no difference which choice you choose. In body of procedure you see a highlighted row on command that will be performed. A command "TurnRound" is on this row. If you want to turn Karel round choose a choice Command / Step in the menu or if you want command "TurnRound" detail debug choose a choice Command / Detail step. Try both alternative you will know a difference between "Step" and "Detail step". With this mechanism you may watch what Karel do at executing commands and you may search errors. If you want to stop debugging choose a choice Command / Reset or Karel may finish work with a choice Command / Run .

Localization

It is theoretical possible translate Karel to any language. Karel is only released with English and Czech language at this time. Program may have localized as environment as source code for the robot Karel. Both can be localized independent. You may have for example program in English language and use elementary commands in Czech language.

Source code lokalization

Karel implicit use name of elementary commands in the language of localized program. If you want to change a language for writing source code choose a choice Setting / Language in the menu. You may here choose a language in which will be source codes for robot Karel.

Program localization in Unix-like systems

Program automatic find what is the localization. xKarel is release in czech language for czech environment and english language for others at this time. If you want have xKarel in czech language set an environment variable LANG to the cs_CZ value. Run xterm for example and if you have as a shell Bash write export LANG=cs_CZ. Now you can run xKarel from this window. If you don't want to set an environment variable run xKarel like this LANG="cs_CZ" xkarel.

Program localization in MS Windows®

Program automatic find what is the localization of Windows® and choose a relevant language. xKarel is release in czech language for czech windows environment and english language for others at this time. If you want to change a language set a relevant language in the control panel.

Questions and answers

Here you find an answers for your probable questions.

Why Karel make an other command when I press "Run" button than is selected in the commands list?
You are debugging a command and you don't stop the debugging. Choose a choice Reset in the menu.
What are the files with "krl" extension?
It is a robot Karel catalogue saved in the file. It is a source code of your commands.
Why isn't open a window "room"?
Window is open, but is hidden with "Catalogue" window. Move a "Catalogue" window to the other place.
What I can do if I don't know how to create a new command?
Look at syntax for the robot Karel by choose a choice Help / Syntax in the menu. Look at step by step too.