Home News Download Introduction Guide Install Roadmap Library NB module Tasks Scripts FAQ history


Karel quick guide

NOTE: this guide is for previous version 2008-10-10. It was replaced by new one and it does not have left Files panel and syntax coloring and code completion.

  1. Working with scripts
  2. Working with town
  3. Next steps

My experience with new programs is to folow tutorial instructions (sometimes several times :-) ) to learn usage of it. So I try to describe Karel using. If you have any recomendation write please.

I suppose your karel is installed and running by some way (see installation advices ).

Working with scripts

  1. Open (or create) project (my name is karel_testing).
    Generated Main class is not necessary so you can delete it.
    NOTE: Specal karek-project has not be implemented yet.
  2. Create new karel script source named towall.
    Menu File / New file / category Other > Empty karel file or the same way by right clicking on source package.
  3. Begin writing "define" word - code completion offers to you keywords.
    You can select one and insert it by enter.
    Continue writing command name "towall" and "as" (in English localization).
    Write full command definiton as folows:
    towall script
    It defines actions to getting robot to the nearest wall.
    NOTE: Code completion is no clever how I planned and indentation is preparing now.
  4. Save it by diskette button.
  5. Select Script to Main window from context menu of our new file.
    action script to main window
    Main window of Karel runtime was opened. You can open it separatelly using menu Karel / Main Karel.
  6. If your script is not in textarea down you didn't save it probably. Activate script tab, save it and retry action. Necessarity of saving will be repared in future version.
  7. Press Run button to run your script. New command TOWALL was defined and it appeared top in command list which are available in dictionary.
  8. Doubleclick on this command TOWALL in commands list.
    Command will be executed and Karel moves to right wall.
    Congratulation! You can programming of robot Karel!
  9. Double click on LEFT command to turn robot left.
  10. Clear script area and type "towall" into it, press Run button and see: Karel is moving up to north wall.
    It was other way to run commands.
  11. Select TOWALL command in list and press Get Command definiton button: .
    Definition of command appeared in textarea. So you can get command and repair it or copy for some similar command.
  12. Rewrite TOWALL name in definition to TOEAST , word WALL to EAST and command STEP replace by LEFT. Run it and try function of new command.
  13. Define new command ROUND

    and try run it.
  14. If you can have running quicker or slower you can set Delay time spinner to wished milisecconds after each atomic command.
  15. Create new karel script file called e.g. dictionary.
  16. When new file opens press Get full dictionary script button .
    Content of dictionary (commands definitions) was loaded into source. You can save it.
    If some problem appeared write me a report please. May be there is some cycle in definition that writer can't handle.
  17. Try to make some error in the script e.g. STEP replace by SPRING and save it.
    Notice node icon in files tree is signed as bad file. Repair and save file.
  18. Content of file is checked on syntax and commends existence in this file.
  19. Enjoy playing with karel.
    Some problems can be appear because all has not be tested yet e.g. complex commands structure, recursion and so on.
  20. If you need to stop running press Stop button .
  21. Send robot into the wall. He will be angry.

Working with town

  1. Create or open some project.
  2. Create new karel town source named e.g. bright name town.
    Menu File / New file / category Other > Empty Town file or the same way by right clicking on source package.
  3. You have standard empty Karel's town 10 x 10 squares to editing.
    You can show or hide helpful grid by Grid button or clear made work by pressing Clear button .
  4. To set or remove wall to selected square click by left mouse button on it.
  5. Try dragging by left mouse button and enjoy raster graphic!
  6. To add sign on square click by right button on it.
    To remobe one sign from square click by left button.
    Some user will certainly try right mouse dragging :-) .
  7. All changes appears in text editor accordingly visual editor.
    town visual editing town text editing
  8. Some changes in text editor can corrupt file structure.
  9. Save your clever graphics.
  10. Try change values in text fields - town size and robot initial position.
  11. To use edited town in runtime select Script to Main window from context menu of our new file.

Next steps


NetBeans editor provides good feature to code completion. If you are typing command name which name you forgret you type beginning and press CTRL+K (repeatedly) until wished word will appear.

CTRL+K searches matching words and offers them.
Commands defined previously in source (dictionary) will be offered in code completion in next release.

Be free to play and program Karel's moving. You can teach him (why to write it if Karel is our friend? ).

Thank to SourceForge.net Logo Reports send to : silhanek (at) users.sourceforge.net RSS Home to top