Watson Imperative Programming Tutorial


Home
Labs
Tutorials
Known Bugs
Schedule
Archive
Members
Contact Information

Editing Code

When the Watson Imperative Lab loads, the 'Code Editor' window is initially blank. To edit code, you must first hit the 'Activity' button and then select an activity to edit. The 'Scratch Pad' activity contains the framework from which you will start writing a new program. The other activities are examples from the textbook.

Code is represented in two colors in the code window. The black text is actual code, and the pink text represents code you still need to fill in. If you move your cursor over the pink text it will be highlighted blue. When the text is highlighted, you can click on it and choose the appropriate replacement. For example, when you load the Scratch Pad activity you can click on either 'statements' or 'declarations' which will create a window with appropriate selections to complete the code.

Sometimes, replacement of text is handled through input windows instead of dropdown boxes. These input windows look slightly different than the other Watson Labs, but they function in the same way.

When you successfully replace all pink text with black text, your program should be ready to run. You can run the program you create using the Program Control Buttons.

Below is an complete example of entering and running an entire program in the Watson Imperative Language. It corresponds to Example #1 in the activities menu. You can also view a longer example of the creation of Example #17 which deals with more difficult constructs such as procedures.

Below is a step-by-step set of instructions to complete the program above:

  1. Click Activity.
  2. Select the Scratch Pad activity to begin a new program.
  3. Click OK after viewing the activity description for the scratch pad.
  4. Move the cursor over the pink text labeled 'name' and click the word. A window will pop up so that you can type in the name of the program. Click the characters in the input window to spell out 'hello world'.
  5. Move the cursor over the pink text labeled 'declarations' and click the word. A menu will pop up to the right. Click 'Delete Highlighted Text' to remove the declarations line, as no declarations are needed for this simple program.
  6. Move the cursor over the pink text labeled 'statements' and click the word. A menu will pop up to the right. Click 'Write Line' to write a complete line.
  7. Move the cursor over the pink text labeled 'expression'. Choose 'Constant-String' from the menu that appears.
  8. Move the cursor over the pink text labeled 'string constant'. An input window will pop up. Enter the text 'Hello World!'.
  9. Click 'Run' to execute the program.

<< Back

Back to Tutorials

Next >>



Home | Labs | Tutorials | Known Bugs | Schedule | Archive | Members | Contact Information

For problems or questions regarding this site or the labs, contact the Watson Project.
Last updated: 10/22/03.