Help on Karel the Robot

česky

Help on Karel the Robot

Layout of desktop

The desktop is divided into three panes: menu in the upper pane, yard in the left pane and help in the right pane, or something else. In the left pane, you can see Karel in his yard and current state beneath the yard. The state is usually "OK", or "yes" or "no" after having done some words. Additionally, information of the depth of nesting and of the number of loop passes is displayed while Karel is running.

In the right pane, you can see either help, dictionary or program listing, as appropriate. The right pane is used also for import and export of the dictionary.

Main menu, export, import

The main menu contains the following controls:

Note:

In addition to the option of exporting and importing the dictionary, the current state of the dictionary can be occasionally saved to the local storage, and the last saved state can then be restored when Karel is started. After changing the dictionary for the first time, you will be asked if you want to save the current state of the dictionary. If so, the dictionary is saved in the local storage in the item "KarelDictionary". In this way, it is possible to promptly resume work that has been interrupted. ATTENTION: The content of the storage is available only on the computer where it was saved and for the logged-in user who saved the content. Do export and import in order to transfer the contents of the dictionary to another computer or to another user.

Dictionary

The dictionary appears in the right pane. Click in the dictionary on the word you wish to select. Choose an activity in the dictionary menu (upper pane), which activity should be performed with the selected word. The dictionary menu contains the following controls:

Word Editing

In the right pane, you can see program listing of the word that is actually selected in the dictionary. You can see a link append beneath the listing. Clicking on that link appends a new statement to the end of the program of the word and starts to edit the new statement. If the word is empty, start to create the program just by clicking on the link.

A radio buttons with the following options appear in the menu:

Quit word editing e.g. by clicking on the "dictionary" button.

Statement Editing

Program listing of the word appears in the right pane. Menu consisting of at least the following controls appears in the upper pane:

The if, while, repeat...times and repeat...until statements may contain some more controls.

If Statement Editing

Program listing of the word appears in the right pane. The following controls may appear in the menu in the upper pane:

While Statement Editing

Program listing of the word appears in the right pane. The following controls may appear in the menu in the upper pane:

Repeat ... Times Statement Editing

Program listing of the word appears in the right pane. The following controls may appear in the menu in the upper pane:

Repeat ... Until Statement Editing

Program listing of the word appears in the right pane. The following controls may appear in the menu in the upper pane:

Running, Word by Word, Animation

Quick running is as quick as possible and displays only a result. Word-by-word running or animation allows you to observe Karels behavior in the yard, actual status and the statements actually being performed. The following controls may appear in the menu:

Constants Settings

You may set the following constants just in javascript in the "karel.htm" file:

dimension          = 8; ...size of the Karels yard
ms_thisfilename    = "karel.htm"; ...name of the file that contains Karel
machine__max_nest  = 1000; ...limit depth of recursion
machine__max_loops = 200; ...max. nr. of repetitions in "while" or "until" loops
mi_speed           = 5; ...default speed of animation (appears in menu)
ms_importfile      = spell["priklady"]; ...default filename to be imported (appears in menu)

As the limit depth of recursion is reached, a message is displayed and Karel stops. Additionally to word calls, also nesting of structured statements "if", "while" and "repeat" is included into the depth of recursion.

Localization

Karel is available now in English and Czech. Every localization has its spelling vocabulary in the "spell_en.js" or "spell_cz.js" file. Do you wish to change the language, create a copy of the appropriate spelling vocabulary and name it "spell.js".

If you wish to create another localization, create a new spelling vocabulary file and a new help file. The spelling vocabulary consists of assignments, text in the desired language is at the right to the equal sign. The "karhelp" item contains name of the helpfile, e.g.:
spell ["karhelp"] = "khelp_en.htm";

Copyright

Karel has been written in javascript by me, (c) Ivan Ryant 2000-2001. I provide it freely for nonprofit use and distribution. Other eventual ways of usage or distribution requires special agreement.

The program is provided as is. The program may contain unintentional faults, thats why I give no guarantees and reject any responsibility for damages that may arise by usage of the program. Tell me please eventual comments or messages of failures preferably by e-mail.

Notes on Version

I wrote this implementation of Karel mainly to learn javascript. That's why I made it a bit dirty and buggy and why the bugs are hard to fix and correct. That was in August 2000–January 2001.

I tried to adapt Karel to Netscape in July–August 2001. I had to completely rewrite menu, because I was not able to set the DISPLAY=none attribute in the DIV element. Thus buttons in the menu could not be just hidden and shown, but the whole frame of menu has to be replaced with new document on every click. Unfortunately, document replacing must not be launched by a button, that is part of the document being replaced, thus I changed all buttons to hyperlinks. Choiceboxes cannot by implemented as SELECT elements for the same reason, therefore I changed them all to hyperlinks, too, and I display the list of options in the frame, where the yard normally appears. Occasionally, I also changed the radiobuttons to hyperlinks. I achieved, the English version goes somewhat, but the Czech version still makes troubles (not only displaying is the issue, but processing in javascript including storing the dictionary in javascript objects, as well).

All the new discovered bugs have been fixed in October-November 2002 and user interface has been improved. I corrected deletion and renaming words in dictionary and the bug in program editing (the second and all the following statements were deleted instead of the first statement in a word). Result of a condition appears now below the yard modified with is/isnt in the if, while and repeat...until statements (e.g. Karel stands at a wall and the if isn't wall command is performed: NO appears now instead of original YES; in the case of the if is wall command YES appears now like originally). The dictionary is exported now into special window, not in the right pane any more - Save as menu command may be used in NS. After import, contents of the dictionary appears in the right pane automatically. Limit on loop repetition has been imposed, thus loops cannot repeat forever (only depth of recursion has been limited originally). Arrays in javascript are indexed now with text strings, that contain merely ASCII characters (simply said, I code strings hexadecimally, but originally, I indexed arrays directly with words from dictionary - I hope, difficulties with Czech language disappear this way).

In autumn 2023, I have ported this implementation of "Karel the Robot" to current versions of Mozilla Firefox 120.0 for Linux Mint (64 bits) and Chromium version 116.0.5845.102 (official build for Debian).

Known Bugs

Using ctrl-R, Karel reloads incorrectly. The same error also occurs when clicking on the corresponding icon in the header of the web browser. Instead, place the cursor in the address bar (e.g. by clicking the mouse) and press Enter to reload the entire page with Karel.

I fixed the other bugs being known up to the December 8, 2023.

In autumn 2023, I have ported "Karel the Robot" to current web browsers. I originally wrote the implementation of Karel for web browsers in 2001 for MSIE5. In 2002, I modified Karel under MSIE6. I tried to adapt Karel also under Netscape Communicator 4.78, unfortunately not with complete success:

I don't know whether Karel works well under other browsers. Fundamental condition must be satisfied that browser supports javascript and that scripts are permitted. In MSIE set option Tools/Internet Options/Security/Own level/Scripting: enable. Troubles can be met if documents are displayed from cache instead of documents fresh generated. My selection in MSIE is Tools/Internet Options/Common/Settings/Check for new versions of cached pages: Automatically. Using "back" button may prove harmless, but it can even surprise you. Troubles with Czech language can be sometimes solved by selecting the Czech codepage (e.g. windows-1250) as a default (e.g. in NS Navigator select View/Character Set/Set Default Character Set). Learn version of the currently running browser here.

Tell me please comments or messages of failures preferably by e-mail.