Tom's Kitchen Computer

(The Reference Manual)

(Jump dirctly to "English IDE")

Introduction

People make programs all the time. They just don't run them on a computer. A program is a sequence of operations done in a particular order to accomplish some task -- like making a peanut butter sandwich or eating a bowl of breakfast cereal. We -- meaning Steve and Tom -- thought this was such a good idea, we think you can teach people to program a computer by showing how it's really what they already know how to do. In English.

Except computers mostly don't understand programs written in English. But Tom's speciality is telling computers to understand some other language besides the ones and zeros that is the computer's native language, so Kitchen is a special-purpose computeer that knows how to run programs written in English. A very small subset of English, but enough to let you see how easy it can be to program a computer.

For you computer geeks out there, Kitchen is Turing-complete. In principle, anything you can do in Java or C you can do in this computer, although a lot slower and less convenient. And your browser window is its only output. But it's a good start, or at least we think so.

The Kitchen Computer is still in development and some parts may not work properly yet. Those we know about are marked here in pink. If you try something and it doesn't work, please tell us so we can fix it.
 

Contents

Error Messages, Why and How to Get Past Them
The Kitchen Program
Kitchen Objects (Nouns)
Kitchen Commands (Verbs)
Variables & Expressions
Conditionals
Iteration
Input & Output
Subroutines
Command Details:
  English Commands
  Sandwich Commands
Regression Tests

Error Messages, Why and How to Get Past Them

(If you are looking for something besides error messages, skip to The Kitchen Program, or else click a topic in the Contents above)

When I wrote this, these were the messages (in alphabetical order) that could show up in the blank space below the counter when your program is running. More messages get added to the program as I make it better, and I try to keep this list up to date, but I don't always succeed. For each message, I tried to tell you why it happens, and (usually) what you can do to get past it. If you can't get past it, you might need to get help from the instructor.

(<cmd> is under construction)

What can I say? The Kitchen computer is a bigger project than I had time to finish. Usually there is another way to say the same thing that the Kitchen computer understands. If you don't know what that is, get help from the instructor.
Assume <if> Not(...) Exit
Telling the computer "if <something> do next iteration" is kind of meaningless at or near the end of the loop, because the default is to do the next iteration. So the computer will try to assume that you really meant to say
if <something> is not true then exit the iteration
which probably has your intended effect.
Assume get <spread> on knife
You told the computer to spread something, and there's a knife in view, but you didn't tell it to get the spread (jam or PB or whatever) on the knife to do that, so it assumed that's what you wanted.
Assume line <nn> is a comment
Comments (notes to be read by people, rather than instructions for the computer) in Tom's Kitchen computer are normally enclosed in (parentheses) but if your command doesn't make any sense, it might be assumed to be a comment. If you intended this line to do something, try simplifying your language.
Assume Next for open repeat
If you start a repeat (iteration), and you indent the lines you want repeated, and if you didn't put a Next command at the end of that indentation, it assumes you meant to do that and inserts it for you. If that wasn't what you iuntended, you might try making the indentation match your intended iteration.
Assume open <object>
If you tell the computer to get something out of a closed container or a space like a cabinet, it might figure out and assume that you wanted it open (which it must be to do that).
Assume repeat begins here
If you indented a portion of your program, and the indented part ends with something resembling a Next command, but there is no corresponding repeat command at the front of that indentation, the computer assumes that it should be there. But it's better if you put it in yourself.
Assume repeat ends here
If you indented a portion of your program, and the indented part begins with something resembling a repeat command, but there is no corresponding Next command at the end of that indentation, the computer assumes that it should be there. But it's better if you put it in yourself.
Assume Stop before end of program
The formal way to end a program is the Stop command. You can do this before the actual end of the program, but we assume it's probably a mistake, perhaps the result of accidentally terminating a subroutine with blank lines, so that the rest of the subroutine runs as main program, and its final Done command is what gave you this warning message.
Assume subroutine ends here
The formal way to end a subroutine is with the Done command, but you can also do it with a blank line or just starting the next subroutine. This message is to let you know the subroutine ended. If that's not what you had in mind, you might put some kind of comment in your (otherwise) blank line. See "Subroutines" for more information.
Assume subroutine <name> ended
The formal way to end a subroutine is with the Done command, but you can also do it with one or more blank lines. This message is to let you know the previous subroutine ended and you are now executing main program. If that's not what you had in mind, you might put some kind of comment in your (otherwise) blank line. See "Subroutines" for more information.
Choose from list by 'item .. of var' or 'var[..]'
You can put items into a list using one of these forms:
put <value> into item <index> of <variable>
put <value> into <variable> item <index>
let item <index> of <variable> be <value>
let <variable> item <index> be <value>
let <variable> [ <index> ] = <value>
You can get items out of a list using one of these forms:
item <index> of <variable>
<variable> [ <index> ]
You get this message if you omitted the <index> value or the left '[' or right bracket ']' or the word "item" or in some cases the word "of". You might also get it if you try to name a variable "item".
I can't <verb> <object> unless it's open
You need to open a jug or box of cereal before you can pour it into your breakfast bowl. Sometimes the computer can figure it out and do it for you, but apparently not this time.
I can't spread <object> there
Kitchen computer knows how to spread jam and peanut butter on bread. If you get too creative, the computer will just get confused.
I don't know how long to wait
The computer recognized that this is a wait command, but you did not say (clearly) how long.
I don't know how to <verb>
The computer recognized that this is a verb, but it has not yet been programmed to do that. Maybe next week.
I don't know how to <verb> a <object>
The computer recognized this verb, but it has not been programmed to do it to that object.
I don't know what <time or date> it is
Something went wrong with this request, probably not your fault.
I don't know what <word> means
There are over a 100,000 words in the English language, but Tom's Kitchen computer only knows a couple dozen or so. This word is not one of them.
I don't know what color <object> is
Some objects obviously have a color, and the Kitchen computer knows what color they are. Others are plain, so Tom didn't tell the computer what color they are. I guess white is still a color, but we had to stop somewhere.
I don't know what to do
Each line of your program (unless it's a comment, a note to yourself inside parentheses) each line should begin with a verb that Tom's Kitchen computer knows (see the list below).
I don't know what value <object> is
Some objects can have a numerical value, like how much cereal there is in the bowl, and the Kitchen computer knows what that value is. Most objects have no metric that can change value (apart from location), so if you ask for it in some way that implies you want a value, the computer complains.
I don't know where to <verb> <object>
You can move an object somewhere, or pour a liquid or cereal into a container, or else dip the spoon into a bowl of cereal, but if it's not obvious where you want this to happen, you need to tell the computer. Maybe what seems obvious to you is not obvious to the computer. Most programming languages, nothing is obvious, everything must be spelled out explicitly.
I don't see a <object> to <verb>
You can move an object somewhere, or pour a liquid or cereal into a container, or else dip the spoon into a bowl of cereal, but if the object is not out where you (and the computer) can see it, it's not possible.
I don't see anything to <verb>
Tom's Kitchen computer knows how to eat a few things (like some cereal on a spoon), but some things you might know how to eat, the computer does not.
I don't see bread to spread <object> on
Kitchen computer knows how to spread jam and peanut butter on bread, but it needs to see a slice of bread out in the open to do that.
I don't see two pieces of bread to put together
The computer thought you tried to tell it to put two pieces of bread together to make a sandwich, but it doesn't see two pieces of bread on the same plate, or maybe it just got confused trying to do it.
I don't seem to have any <object>
Kitchen computer knows the names of several ingredients that didn't make it in for this release. Maybe some time in the future.
I need a knife to <verb> <object>
The computer only knows how to spread jam or PB on bread using a knife, but there's no knife visible to use for that purpose..
I need a variable for <verb>
If you use one of the commands for giving a value to a variable, then obviously you need to give it a variable name. Variable names start with a letter and come immediately after the command name.
I need an object to <verb>
Most of the things (verbs) you can tell the Kitchen computer to do, you need to tell it what to do it to. The computer did not see anything in your command that looked like something this verb can act on.
I'm all confused about line <nn>
This is a catch-all failure of the computer to make any sense of your command. Try saying in a different way whatever it is you wanted the computer to do.
I'm not ready for different dishes at the same time
Some things (like make a sandwich) the Kitchen computer does on a plate, and other things (like eat cereal) it does in a bowl, but it gets confused if you try to use both in the same program.
Line <nn> is getting too complicated for me
This happens if you try to do something with a piece of bread that you didn't get out of the loaf wrapper, or if it already has something spread on it, or something like that.
Looks like missing 'let'
All commands, including putting a value into a variable, must begin with a command word. Most programming languages have other ways of knowing about assignments, so there's no command word there, but it doesn't read like real English -- in English "A = A+B" is nonsense, or else an equation that you can solve for B=0, but then why would you want to do that?
Missing end of quotation
You probably forgot the end of a quoted text string, or maybe you used an apostrophe in a word that was not properly quoted and was not recognized as a comment. Quoted text can be surrounded by double quotes ("), double quotes ('), or grave accents (`). If you need one of those symbols in your quoted text, use a pair of the others to quote it. You can use the concatenation operator (#) to put different quotation fragments together.
Next must be unconditional
Some other programming languages use the word "next" as a command like "exit" but to restart the iteration at the top, and if you have used those languages, you might be tempted to try it here. In Kitchen "Next" is more like a boundary, marking the end of what is to be repeated. The Kitchen compiler will try to turn a conditional
if sometest then next
into
if not sometest then exit
but if it does not succeed, you get this message.
Please do things one at a time
If you build a command that has several different words that say order things are done, the computer gets confused. Try to break your command into smaller parts.
There is no loop to do <more> here
You can restart an iteration before its next command in the Kitchen computer with a more command. You cannot go back to the front of a loop that is not currently active, so the more command only works inside an iteration.
There is no <if> for the <otherwise>
An else or otherwise must always directly follow an if.
There is no loop to do <more> here
Within an iteration you can jump back to the front from anywhere inside the iteration, but it makes no sense if you try to do this outside the iteration..
There is no repeat for the <next>
An iteration in the Kitchen computer starts with a repeat command and ends with a next command. Sometimes the computer can figure out where the repeat belongs by your indentation, but apparently not this time. It works better if you are explicit about where your iteration begins and ends.
There is nothing to <exit> here
The exit command drops you out of an iteration before the number of iterations has run out, or from somewhere in the loop other than the end. But it doesn't make any sense outside an iteration.
There isn't any <object> there
You can tell the computer to get some things "from" a location (like the cabinet or fridge), but if it's not there, it can't do it. This is how it says that it can't.
We don't need any <object> in this kitchen
The Kitchen computer was designed to do a simple breakfast of a bowl of cereal or to make a PBJ sandwich. Some ingredients are not useful for those two purposes.
We ran out of bread
There are eight slices of bread in the load. If you make too many sandwiches, or if you waste the bread, it will run out.
You count different than I do
If you get several slices of bread out, you can refer to them by number (first, second, etc), but if you ask for a slice that isn't out of the loaf, what can it do?

The Kitchen Program

The program is what you write, in a very limited subset of the English language. Like all natural languages, English can do some very subtle nuances of meaning, but the Kitchen computer will not understand you if you try that. Keep it simple. Some things ought to work -- and maybe will in a future release -- but they don't work now, so feel free to try different ways of saying the same thing. You can edit your program in the edit panel to the left of the Kitchen image on the IDE web page, or you can use some other text editor and just paste it into the edit panel.

If you number your lines sequentially (there's a button to do that), then if you make a mistake that the computer can tell you about, the line numbers will match. Or you can leave the line numbers off, because the Kitchen computer ignores them. The Kitchen computer also ignores whether you capitalize your commands or not. When you get into Java you must be much more careful about those kinds of things.

The Kitchen computer knows how to make a peanut butter sandwich (with a few variations), and it knows how to prepare and eat a bowl of cereal. It's not much, but it gives you an idea how computer programs work, a sequence of steps done in order, operating on objects and values, where the steps may be repeated and/or based on testable conditions. You can also give a name to a part of your program, then call it up as a subroutine from other places in your program.

Generally, your programs should consist of a sequence of commands, one line each, where each command begins with a verb, what you want the Kitchen computer to do when it gets to that line. We recommend you number your lines, but it's not necessary.

Most commands tell the computer what to do to an object, which can be one of the common things you might find in a kitchen, but you can also do things with numbers and give names to values (variables). It is more limited than a real programming language, but it gets you started.

You can add comments (notes to yourself) in {curly braces, shift-[bracket] on most keyboards} (parentheses sometimes work as in some of the Preface example programs, but not on variable assignment lines).

Your best bet is to start with one of the Preface examples, then modify it to do what you want, or use it as an example to try something different.

The next two sections list the objects (nouns) the Kitchen computer knows about, and the commands (verbs) that it knows how to do to those things.
 

Kitchen Objects (Nouns)

Locations

[left or rightdish or pantry] cabinet or cupboard or shelf
The dish cabinet is to the left, the pantry cabinet is to the right. If you don't specify which cabinet you want, the Kitchen computer will make a guess.

refrigerator or fridge for things best kept cold

(silverware) drawer

counter
Normally you do not need to tell the Kitchen computer to put something on the counter, it assumes that's where something goes if you didn't say where.

back or away
When you are finished with objects that came out of a cabinet or fridge or drawer, you can put it back.
 

The Kitchen computer needs to be able to see what you are asking it to do something to, and if you can't see it on the screen, it probably can't see it either. Sometimes it will Assume to open something that needs opening, but other computers are not so smart, so you shouldn't get in the habit of letting it assume anything.
 

Dishes

We have three plates and three bowls. Normally you would use only one of them at a time.

Although the drawer appears to be full of silverware, the Kitchen computer only knows about one knife, one spoon, and one fork.
 

Pantry Items

We have one box of "Cheery Oats" cereal, one loaf of bread, one jar of peanut butter (PB) and up to three jars of different flavors of jam. There are eight slices of bread in the loaf.
 

Fridge Items

There is a jug of milk and a butter dish and a jar of mayonaise in the fridge. Some deli meats and cheese are on the way, but they haven't arrived yet.
 

It

In English the pronoun "it" generally refers to the most recent object referred to by name. Sometimes that also works in the Kitchen computer, but it's better if you tell the computer exactly what you want it to do. If you choose or see an object, then it refers to that object until something else gets the focus later in the program. After a conditional, it usually refers to the result of the test, either true or false. After input with no variable specified, it contains whatever came in.
 

Kitchen Commands (Verbs)

You can open the locations to get out the items stored there, and you can open the food containers to get a serving. You can also close them when you are done.

You can get or take or remove an item from its location (which moves it to an available location on the counter), and you can get or take or remove some jam or PB from its jar [get is not yet working properly]. Milk and cereal should be poured. You can put a slice of bread on a plate, and you can spread jam or PB on it, then you can put (two slices) together  or flip one slice over the other to finish your sandwich. You can dip or put the spoon into the bowl of cereal to get some cereal, then lift it into the air to eat it.

You can choose or see an object and then refer to it using it (until something else becomes it).

There is a message line below the Kitchen image, which reports program assumptions and problems the Kitchen computer cannot resolve on its own (see the list here). You can also put your own message on that line with the message (msg, print, say, show) command and a quoted string or defined variable with the text to display.

You can ask what [date or time] is it, and the result will be displayed on the message line, and also available in it. You can set the date or day of the week using it is [date], and then the date tests will use the new date.

Other commands are described in the following three sections.
 

Six Ideas

An important part of programming as we teach it is that there are six fundamental programming elements or concepts, six different things that a Turing-complete computer can do, and everything it can do is one of those six (or a combination of them), and pretty much nothing else. Once you know these Six Things and how to spell them in a particular programming language, then you can write any program in that language that can be written. Here are the Six, with links to how they are spelled in the English computer:
Sequence -- (no link, these are just the lines of your English program), maybe Wait and Break count here

Conditional -- If ... Then ... Otherwise

Iteration -- Repeat ... Next

Input/Output -- Input or reading the time or date / Print or changing the pixels in the Kitchen image using one of the object commands like Open or Get or Spread

Variables -- Let plus some specialized operations like Round and Substring

Subroutines -- "Quoted Name" .. Done called by Do

Variables & Expressions

The Kitchen computer can do simple math on numbers and store the results in variables, or print them on the message line. Numerical values can be combined with the four arithmetic operators ( + - * / ) and parts of the calculation grouped with parentheses as in any programming language (don't worry about it, we will explain this when we get to it, later). You can also put pieces of text together using the concatenation operator # or cat or concatenate. Here is an example:
Message "The sum of " # 1 # " plus " # 2 # " is " # 1+2
You can put values (numbers or text) into named variables, but put can mean several different things (and the computer might guess wrong which you wanted), so the best way to do it is using the Let (or variable) command, like this:
Let myVar = 12
Variable calc = myVar*3+27 (=63 in calc)
The variable name is always a single word with only letters and digits (except it must begin with a letter). The value you put in a variable stays there until you put something else there, or your program ends. If this is too complicated, don't worry, we'll learn about variables in detail later, and more when we get to Java.

The Kitchen computer needs to know that you intend for a word you are using to be a variable. The best way is for you to define it in a Variable command, but it can also figure it out when you use it in Let or Input commands, but not inside a conditional.

When a variable has a number in it, you can round it to the nearest whole number (integer) or truncate it towards zero (discard the decimal part without rounding up):

Let myVar = 20/3 {=3.333..}
Round myVar      {now = 3}

When a variable has text characters in it, you can extract a substring of those characters, either into the same variable (discarding the remaining characters) or else into another variable. The number of characters to skip over from the front is in a value that follows a comma after the variable name (default is zero if none specified), and the number of characters to take is in a second value after a second comma (default is one).
Let myVar = "abcdefgh"
Substring myVar,3,4  {leaves myVar = "defg"}
Substring front = myVar {front = "a" and myVar is unchanged}

A variable can also be an array or list of numbered items, where each item can be anything you can put into a variable (except another list, wait for Java to do that). You can use the English words 'itemnumberof theList' or the more conventional bracket notation 'theList[number]' to access the array elements, and the array is dynamically sized to accept the largest index you put into it -- except it probably will fail for very large subscripts, or for anything less than one:
List myVar = 3,".",1,4,1,5,9
Array theList
Let item 1 of theList = myVar[2]
Let theList[9] = 000

Iteration

You can repeat one or more lines of your program. The best way to do this is to start with a repeat command and finish the part to be repeated with a next command, both in the same subroutine. If you use only one of those keywords but indent the repeated portion, the Kitchen computer will assume the indented part is to be repeated, as in the Breakfast program. You should put on the same line with the repeat command a number of times you want it to repeat. If you don't know, use a large number -- or just leave the number off and the Kitchen computer will assume 99. If your program decides to end the iteration early, you can use the exit command, perhaps in a conditional. The Breakfast program used 'do it again' to restart the iteration at the beginning (in a conditional) and that might also work for you, if you need to do that.
 

Conditionals

After your program has calculated a value, you can later test that value and do different parts of your program depending on the result. The command to do this is if followed by a variable or calculation that can be true or false, such as when you compare two values (variables or numbers) to see if they are equal or greater or whatever:
if myVar < calc message "less"
After the value to be calculated, you should put a command to be executed if the result is true. You can put it on the same line or the next line. In this example, if myVar is equal to calc, the condition being tested (less) is false, so nothing is printed on the message line.

After a sequence of one or more conditionals using if, you can say else or otherwise to pick up the conditions the ifs missed:

if it is Tuesday take peach
if it is Thursday take grape jelly
otherwise take strawberry


The Kitchen computer is not smart enough to figure out that a set of conditions ending in else all go together if some of those if-lines call subroutines or even if they do repeats. When you need an else or otherwise at the end of that kind of complex conditional, you might use it to set variables you can test in a simpler fashion.

You can also test whether a bowl or spoon is empty and certain parts of the date or time, like what day (Sunday is 1, Monday is 2) or month or year it is, like

If it's Saturday choose the Strawberry jam


The Kitchen computer does not (at this time) know how to do more than one command line in connection with an if-condition, but that one command can be a repeat 1 (do it only once) and then everything between the repeat and its final next happens only when the condition is true:

if calc=3 repeat 1
  msg "Do this first"
  if myVar < calc exit
  msg "then this, but not if myVar is less than 3"
  msg "none of this happens if calc is not equal to 3"
  next (done, the repeat is finished and so is the conditional)
msg "this happens immediately if the first condition is false"

Input & Output

Output is obvious: it's the message (or display or show or say or print) command, and it displays your message on the status line below the kitchen image. If your program makes no mention of any kitchen objects, but does some lines of output, part or all of the kitchen image will be covered over with a panel that displays the last 15 lines of your output. If you are doing things to kitchen objects, then obviously you want to see what is happening, so the panel does not cover them.

Input uses the command input optionally followed by a variable name that you want the input text or number to be loaded into (default is it), and an optional number specifying how long input should be limited to. If that number is negative, then the input value must be a number (anything else the user types will be ignored). If you give it a length 1, then the input must be a single letter, which is automatically capitalized. Unless the user types in the whole maximum size, they need to end their input with the Enter key. Or they can wait until it times out, which is the same thing. The computer will flash instructions to the user on the input line, including a warning when the timeout is approaching.
 

Subroutines

You can designate some part of your program by name to be a subroutine by giving it a name (in quotes, in a line by itself at the front of the subroutine), and then run it from some other part of your program. The subroutine ends with the command done, or the beginning of another subroutine, or a blank line, or else by default at the end of the program. The command do with the name is used to activate a subroutine, or you can use the name of a subroutine alone on the command line:
do part1
part2
do part2 (again)

"part1"
let x=23
done

"part2"
msg "x=" # x
let x=x+1
done
 

This displays two messages, first "x=23" then "x=24".

We don't recommend it, but subroutine names can be multiple words, so long as you don't use more than one space between them. You should avoid using the same name for a subroutine that is significant in some other part of your program (like command or variable names) because the subroutine name will override any other usage (possibly resulting in an error the Kitchen computer cannot guess a reasonable recovery from).
 

Recursion

We do not emphasize it at this skill level, but it is possible for a subroutine to call itself (or call another subroutine that calls the first subroutine), and you can make very complicated programs that are not possible otherwise. Simple recursion (calling back to yourself at the end) is equivalent to iteration, which is the preferred way to do it. The important thing to keep in mind is that a recursive subroutine stack should always get back out (otherwise the computer runs out of memory and your program crashes). This is hard to enforce, which is why we don't recommend recursion to beginning programmers.
 

Command Details

At the bottom of the Integrated Development Environment page where Kitchen programs run is a summary of the commands you can use, linked to the descriptions in this section. There are two summaries, one for general (text-based) programming in English, and another specific to making sandwiches in the Kitchen view.

The command name (shown in bold) must be first on its line (after the line number, if any). Other required words are shown in monospace, or if optional, [inside brackets]. Descriptive terms in italic are used for parameters which might be any of several items of that kind.

Case (capitals or lower case) is not significant.
 

English Commands

In this section, each command is identified as one of the "Six Concepts" by a letter inside curly braces:
{S} Subroutines (start with quoted name, end with Done, called by Do)
{S} Sequence (implied by separate lines)
{C} Conditional
{R} Iteration (Repeat)
{I}/{O} Input/Output
{V} Variable
Input variable [sizetype] {I} Repeat [count] {R} If condition [then] {C}
Print/Say/Display values {O} Next {R} Else/Otherwise {C}
Let name [= value] {V} Exit/Again {R} Pause/Breakpoint
Round/Truncate variable {V} Wait seconds {O} Substring/Character variable
[= source][, offset[, size]] {V}
Do subroutineName {S} "subroutineName" ... Done {S}

Let/Variable/Box/Arrayname [= value] {V}

Purpose

To set a variable name to a particular value, possibly an arithmetic combination of several variables and/or numbers.

Explanation

This can be used to declare a name to be a variable, and optionally to give it a value. Using the name in other commands that require a variable will also declare it, but not inside a conditional. The value can be an arbitrary expression of values (numbers, variables, quoted strings) connected by operators. Unlike more common languages, the keyword Let is required for assignments.

Examples

Variable myVar {declares it to be a variable, but no value}
Let myVar = "Hello world!" {now has 12 characters}
Let aNum = 1+2 {=3}
Let myVar = aNum-5 # myVar {= "-2Hello world!"}
Let aNum = aNum / myVar {= -1.5 (ignores what is not a number)}
Array myVar = "one",2,aNum,"for" {four separate list items}
Let item 2 of myVar = myVar[4] { = "one","for",-1.5,"for"}


Print/Show/Say/Displayvalues {O}

Purpose

To display text values in the output panel, or else on a single line under the Kitchen image.

Explanation

This prints whatever value or values on a single line of output, shown on a separate output panel.

Examples

Print "2+3=" 2+3  {shows: '2+3=5'}
{assume aNum as calculated above...}
Say "aNum = " # aNum {shows 'aNum = -1.5'}


Input variable [sizetype] {I}

Purpose

The Input command is used to get values into the computer that are not known when the program is written. These values are typed in on the keyboard by the user, and stored in the variable.

Explanation

The interpreter waits for the user to type in some input (of the appropriate type, if specified) on a line by itself, and stores that value into the specified variable. It times out and accepts whatever has been typed so far after about 20 seconds of inactivity.

If the sizetype is negative, the entered value must be a number (non-number characters will be ignored). If greater than zero, it specifies the number of characters that will be accepted (no EnterKey needed); a length exactly one also capitalizes any letter that comes. If omitted, there are no qualifications on the input.

Using a variable name in an Input command is sufficient to declare it as a variable.

Examples

Input aLine {gets any characters up to the Enter key or timeout}
Input aNum -1 {gets only a number}
Input max4 4 {gets 4 characters or less}
Input letter 1 {capitalizes a single letter, could be ""}
If condition [then] command {C}

Purpose

This command is used to decide whether to do a command, based on a condition anticipated but not known when the program is written.

Explanation

If the condition evaluates to true, the single command (either on the same line or -- better -- the following line) is executed. If it evaluates to false, the command is skipped. The only way to skip more than one command under the control of a single If-test is to enclose them inside a 'Repeat 1' command.

[Work-Around]  There are known problems with some commands on the same line as the conditional, particularly implied subroutine calls (without the command name Do) and any command other than Let when it includes an '=' symbol. It works fine on (two) separate lines.

Examples

Input letter 1
If letter < " " then Print "Nothing came"
if letter > 'Z' then Print "Not a letter" {see ASCII Chart}
if letter < "A" then print "could be a number or punctuation"
Otherwise Print "It's a letter!"


Else/Otherwise command {C}

Purpose

This command specifies what command to do if none of the immediate preceding conditionals is true.

Explanation

After a contiguous sequence of If-tests with no contained iterations or subroutine calls, if none of them evaluated true, then the command of the following Otherwise is executed.

Example

{see IF-example above}


Repeat [count] {R}
  commands
Next

Purpose

This pair of commands marks the beginning and end of code (commands) to be repeated some count number of times. They must both be in the same subroutine.

Explanation

This is the basic iterator, to repeat any number of commands, which is between the Repeat and Next commands. If a count is specified, that is the number of times (possibly zero) the sequence of commands is executed. If no count is specified, 99 is assumed. If there is only one iteration in a program, and the commands (body) are indented, then the compiler may attempt to infer a missing Repeat or Next,  but you shouldn't depend on that.

Example

Let aNum = 0
Repeat 7
  add 1 to aNum
  if aNum>5.2 then Exit
  if aNum=3 then Again
  Print aNum  {prints 1,2,4,5 on four separate lines}
  Next


Exit/Again {R}

Purpose

Normally an iteration goes from start (the line after the Repeat command) to finish (the line before the Next command) the specified number of times, but these commands can bypass the ending and Exit out of the repeat or start over Again.

Explanation

Used with a conditional inside an iteration, these commands can force an early termination (Exit) or jump to the next iteration (Again) of the nearest enclosing iteration. If no other Exit has been specified, the compiler will invert the controlling conditional and convert an Again at the end of an iteration into an Exit, but you shouldn't depend on that.

Again only works on the same line as its controlling If (it doesn't make sense otherwise, just use Next).

Example

{see Repeat-example above}


" subroutineName" {S}
  commands
Done

Purpose

These two lines define the beginning and end of a subroutine named subroutineName

Explanation

This is the basic subroutine form, starting with the name inside (double) quotation marks and ending with the word "Done" on its own line. Not recommended, but a blank line or the beginning of another subroutine also terminates the previous subroutine. Single spaces are permitted in subroutine names, but not recommended. See "Subroutines" above for more information.

Example

Let X = 3 {main program code}

"PrintX" {start subroutine}
  print X {what this subroutine does}
  Done  {end of subroutine}

Do PrintX {call the subroutine, X=3}
add 1 to X
Do PrintX {call it again, this time X=4}

{this prints 3,4 on two separate lines}


Do subroutineName {S}

Purpose

This is the preferred way to call a subroutine.

Explanation

This command is the approved way to call a subroutine, but the subroutine name alone on a line also works. See "Subroutines" above for more information.

Example

{see Subroutine-example above}


Round/Truncate variable {V}

Purpose

The result of a divide or input operation could have a fractional part; this forces that result variable to be an integer.

Explanation

The value in the variable is converted to a number, then rounded or truncated to an integer and put back into the variable. Rounding is IEEE-754 compliant, that is, if the variable is exactly halfway between two integers, the result is even; otherwise the result is whichever is closer. Note for example, that the IRS always rounds halfway up.

Examples

Let rUp = 3.5
Let rDn = 2.5
Let closer = 3.49999
Let aNum = 3.9999
Round rUp {= 4}
Round rDn {= 2}
Round closer {= 3}
Truncate aNum {= 3}


Substring/Character variable [= source] [, offset [, size]] {V}

Purpose

This extracts one or more characters from anywhere in a string (variable value).

Explanation

This extracts a substring of characters from a source variable and stores the result into the specified destination variable (which will also be the source if not separately specified), beginning after offset characters (or zero if no offset is specified) for a length size (or a single character, if no size is specified. If the specified size is one, and it's a letter, it will be capitalized.

[Work-around] If you need to use this command with the optional source variable under the control of a conditional, the '=' will probably be mistaken for a missing 'Let' command (error). It works OK if you split the line so the conditional is on the first line and the Substring or Character command is on the second line.

Examples

Let myVar = "Hello world!"
Let aNum = 3
Character letter = myVar,6 {gets "W"}
Substring myVar,aNum,aNum-1 {gets "lo"}


Wait seconds {O}

Purpose

This is a way to delay execution for a period of time (seconds).

Explanation

This inserts a delay into the execution, mostly for visual timing.

Examples

Wait 0.66 {wait 2/3 of a second before continuing}


Pause/Breakpoint

Purpose

If you have a long-running program that is misbehaving, so that it is not convenient to Step through from the beginning to get to the place where you need to examine the program state (variables, call stack), you can set a breakpoint on a nearby line so it will pause there for examination.

Explanation

This command causes the English IDE to pause on the next line and show the machine state (variable values and what subroutine calls got you here). Click the blue Step button to advance to the next line, or the green Fast button to resume at full speed, or the red STOP button to stop the program entirely so you can make changes to it (or else delete or add another breakpoint).

Examples

Pause {break into the debugger when execution hits this line}

 

Sandwich Commands

Close cabinet. Get PB from pantry. Open jelly. Put loaf back.
Close drawer. Get piece of bread. Open other cabinet. Put PB back.
Close jam. Get plate from cupboard.  Open pantry cabinet. Get another piece of bread.
Close loaf. If T/F then Otherwise Repeat num ... Next
Close peanut butter. It is date Open peanut butter. Spread jam on bread.
Get bread from pantry.  Open bread. Put bread pieces together.  Spread jelly on bread.
Get jam from pantry. Open cabinet. Put it on plate. Spread PB on bread.
Get jelly from pantry. Open drawer. Put jam back.
Get knife from drawer. Open jam. Put jelly back.

Close container
Open container

Container objects (cabinet/drawer/refrigerator/jam/PB/bread loaf/milk) can be closed (default, and for storage), or open for extracting contents. The contents cannot be extracted when the container is closed.


Get/Take object [fromcontainer]

This verb is used to extract an object from its container. It is not necessary to specify the container unless the container is closed (opening it will be assumed), and that only works for long-term storage containers like cabinet/drawer/refrigerator.


Put object (away/back)

An object that came out of a container (cabinet/drawer/refrigerator) can be returned to its storage location using this command. The destination word away or back is required to distinguish this command from putting a value into a variable.


Spread condiment

This command spreads some of the specified spreadable condiment (peanut butter/jam/flavor) on whatever slice of bread is available to take it.


[2022 October 5]