Karel - A Quick Introduction

Step 1: Login to the MathSci network. (If you do not have an account on the MathSci network, use the username MATH01, or MATH02, or MATH03, ... or MATH29).
Step 2: From the DOS menu, select the options O = Other Menus, then L = Languages. You will see two choices that we shall need on the right side of the screen: E = Text Editor, K = Karel the Robot

As a rule, you use the Text Editor to create your Karel program, then you save your file and quit the Text Editor. Next, you call up the Karel program to create your world and execute your program. Here are the details.

Step 3: Select E = Text Editor. From the menu, select File | New (using either the mouse or the ALT key in combination with the appropriate letter).
Step 4: Type your Karel program. As an example, enter the following program:
      BEGINNING-OF-PROGRAM
         BEGINNING-OF-EXECUTION
            move;
            turnleft;
            move;
            turnleft;
            move;
            turnleft;
            move;
            turnleft;
            turnoff
         END-OF-EXECUTION
      END-OF-PROGRAM
Step 5: Save your program by selecting File | Save As … If you are using your own MathSci account, save it on drive Z. If you are using one of the MATH## accounts, you must bring a floppy disk and save to that floppy disk (usually drive A). In our example, type the file name Z:\TEST.KRL and hit ENTER.
Step 6: Exit the Text Editor by selecting File | Exit and start the Karel program by selecting K = Karel the Robot.
Step 7: The Karel simulator will ask you for a file name of the program. Enter, in our example, Z:\TEST.KRL. Next, hit RETURN to have any lexical or syntactical errors displayed on the screen. If you typed the above lines exactly as indicat ed, you should see a message that there are no lexical or syntactical errors. Hit RETURN to continue.
Step 8: You will be asked whether to read a ‘World’ from disk, or build a new one. Hit ‘B’ to build a new world, followed by RETURN. Next, hit ‘B’ again, followed by RETURN, to build a new world from scratch. The word builder will now accept your commands. In our case, we do not add any beepers or walls to our world, so hit ‘E’ to leave the World builder (for more details on the world builder, see below). You will be asked to save your world. Enter ‘Y’ and hit RETURN to save your world. Use ‘Z:\TEST.WOR’ as a file name when prompted.
Step 9: Now you are ready to execute. Pick the following options, each time followed by RETURN: A = Automatic Execution, M for medium speed, R for regular mode. One more return will start the simulation: Karel will run into a wall and perform an error shutoff. You will be told which line in your program caused the error, and be offered a chance to r epeat everything.
Step 10: Try to adjust Karel’s position so that he will not run into a wall.

Appendix: Command Summaries

Monitor Mode

Monitor Mode Command Summary: There are 3 parts to each Monitor Command, and their order is important. If any part is omitted, its default value (see []) will be used.

Speed Change([F]ast, [M]edium, or [S]low).
Execution Direction ([+] for advance or [-] for retreat).
Number of instructions to step (default value is 1 primitive).

If only a Speed Change or Execution Direction is supplied, the execution will not advance or retreat. Instead of a number, you may also type B, D, E, I, L, O, P, Q, R, T, or U:

B means retreat execution to the program's Beginning at the present speed.
D means Display the Defined instructions that are currently executing.
E means advance execution to the program's End at the present speed.
I means trace Inside the supplied Instruction name.
L means Look at an arbitrary portion of the world.
O means change the execution Options.
P means Print the definition of a defined instruction.
Q means Quit the program at the fast speed.
R means Re-Draw the display.
T means Trace To the next occurrence of the supplied instruction name.
U means Undo Instruction tracing (cancels the I command).

Explain Mode

Explain Mode Command Summary:

D means Display the defined instructions that are currently executing.
L means Look at an arbitrary portion of the world.
O means change the execution Options.
P means Print the definition of a defined instruction.
R means to Re-Draw the display.
A positive number goes forward that many explanations before reprompting.
A negative number goes forward that many primitives before reprompting.

Note that in Explain Mode, execution can go only forward. Pressing the RETURN key causes Explain Mode to explain the next step.

World Builder

World Builder Command Summary:

M   Move Karel to a new corner.
     "M E 5"   = Move East 5 blocks.
     "M 8,13"  = Move to 8th Street and 13th Avenue.
F   Face Karel in a new compass direction ("F N" = Face North    ).
L   Load beepers in Karel's beeper bag    ("L 3" = Load 3 beepers).
P   Put beepers on Karel's corner.
     "P 2"     = Put 2 beepers on Karel's Corner.
     "P 2 E 5" = Put 2 beepers on the next 5 corners going East.
B   Build a Wall.
     "B NSE"   = Build walls to the North, South, and East.
     "B E 4 N" = Build walls to the East on the next 4 corners going North.
D   Destroy a wall (see "Build a Wall" for examples).
R   Re-Draw the display (in case it is accidentally erased).
E   Exit the world builder and start execution.
S   Save the world and then exit the world builder.
T   Temporarily save the world and then return to the world builder.
K   Kill the entire world (blank it out) and restart building.
?   Print this message.

How to Attach a File to a Mail Message

1. Use your user name and password to login to your computer account on your server as usual. Then select the electronic mail program by picking M from the menu.
2. Create a new message as usual by selecting Send from the menu on the top of the screen. Using the keyboard, you would press ALT-S to select the Send option from the menu. A new window appears with a list of choices. You can select an entry by us ing the arrow keys. Select the entry labeled New Mail and confirm your selection by hitting RETURN.
3. You will see a new windows where you can enter the recipient of your message as well as the subject and the actual text. In the field labeled To: enter the address of the intended recipient of your message. My e-mail address is WACHSMBE. Use the TAB key until the cursor is in the field labeled Subject and enter the subject of your message. Hit the TAB key again and type the text of your message, such as 'Enclosed is my first Pascal programming assignment.'
4. To include your Pascal Program, select File from the menu by hitting ALT-F. Then use the arrow keys to select the entry labeled Attach File and hit RETURN. Hit RETURN again to see a list of all files in your personal directory. Use the arrow key s to select the correct Pascal file you want to include in your message. When that file name is highlighted, press A (or 1) for Attach File to attach that file to your message.
5. You should next see the previous windows, displaying your original message text, recipient, and subject. At the bottom part of your message is a box called Attachments. That box should contain the name of the Pascal file that you have selected i n the previous step. If everything is correct, send your message by pressing F9.
6. You can now send additional messages, with or without included files, by repeating the above procedure. To quit the mail program, hit F7 and confirm that you want to exit the program if necessary.

If you have a mouse that works with your mail program on the computer that you are using, you can use it instead of the ALT-key combinations to select the appropriate topics from the various menus. You usually use the mouse to point to an entry on a menu and then click once, or if that shows no result twice in rapid succession, to select the corresponding item. If you need more information about electronic mail at Seton Hall, you can pick up an extensive help package for electronic mail at the help desk in Corrigan Hall.