Chapter 1

From BR Wiki
Jump to navigation Jump to search

1.1 Start up & Typing

Now locate the HOME key on your keyboard, and press it. It should cause your cursor to move to the first position in the first row of this program line. A single line is considered to be anything that follows a line number, no matter how many rows it takes up. Now find the key marked END, and press that; this causes the cursor to move to the last character in the line.

Recall the activity that you did in the Introduction section called "Using the Keyboard", in which you typed 10! with two rows of Ws. Please repeat this step. Let's now change the Ws to Ts. To do this, press your "Home" key again so that the cursor goes back to the beginning of the line. Find the right arrow key (->), and press that until the cursor is under the first W. Press the T key; this should print a T, and move all the W’s to the right.

To replace the first W with a T, push the INSERT button on your keyboard. In the mode field of your status line, the START is replaced with OVER. Now, if you hold the T key down long enough, all the W’s in the line will be replaced with T’s, as Business Rules! types over the letters with new letters.

How do you just get rid of something? There are two ways: with the "Del" key, which deletes the character that the cursor is currently sitting on, and backspace, which deletes the character just before the cursor. Try these two keys out by deleting every letter in this line except the line number and the exclamation point.

When you've got everything deleted, type the following in:

00010 ! The wombat ran under the table. 

Once you've got this line typed in, go back and add the word "kitchen" between the words "the" and "table". You should find that you end up having to retype the end of the line because the Business Rules! typeover mode is on by default. To turn typeover mode off for a moment while you insert the word, press the "INSERT" key and type the word where it should appear.

Go ahead and continue to experiment with your keyboard. Focus especially on what happens when you use the four arrow keys and the Ins, Home, and End keys. You should have a good understanding of how each of these keys operates before you continue on to Chapter 2. If you accidentally erase the exclamation point and cause an error, it's no big deal. Simply "insert" a space and exclamation point after the line number and press ENTER.

Quick Quiz 1.1

1)Which key causes the cursor to move one character to the left without deleting anything?
a) The Backspace key.
b) The left arrow key.
c) The Ins key.

2)Which key erases the character that the cursor is sitting on?
a) The Backspace key.
b) The space bar.
c) The Del key.

3) What is the quickest way to replace the word "wombat" with the word "gerbil"?
a) Remain in typeover mode and type the new word directly over the old word.
b) Push the Ins key to enter insert mode. Type in the new word, then use the Del key to delete the old word.
c) Retype the entire line.


Answers 1.1

1.2 Statement Syntax

Another important thing that you should know before you launch into programming is a little bit of information about statement syntax. Syntax is the word we use to describe the special order and punctuation that Business Rules! requires for commands and statements that you enter. You will see several syntax sentences in the lessons and chapters of this tutorial. They do not represent an actual command or statement; instead, they show you the general form of the command or statement in question. As an example, look at the following simplified syntax sentence for the Let statement:

Line# LET variable = expression

If you typed the above syntax sentence into BR exactly as it is shown, you'd cause an error, because it begins with the word “Line#” instead of an actual number). Only the words in capital letters (such as LET, which is called a keyword) and the punctuation marks (such as the equal sign) are meant literally while the words “variable” and “expression” will be replaced later with different values as you write your program.

BR! has a very specific structured syntax; the placement of each term is important.

The portions of a syntax sentence that are shown in small letters are each meant to describe the types of items that can appear in its place. Each of the words has a very specific definition that you will learn about in an upcoming chapter. As an example, the "variable" portion of the LET statement can be either a numeric or string variable (you will learn about these soon), of which there are limitless possibilities.

The important thing to remember with syntax sentences is that the portions in capital letters are meant literally. The LET keyword shown in the above syntax sentence is required in the LET statement (although you may type it in with either uppercase or lowercase letters).

So, if you entered a line number (such as 10), the word LET, the name of a variable (such as X), an equal sign and an expression (such as 14 + 9), then Business Rules! would accept the information without a complaint:

00010 LET X = 14 + 9 

Also, note that the punctuation in a syntax sentence often has special functions. A comma, for instance, is almost always used to separate individual items in a list. Also, when a colon (:) is used, it typically separates one major portion of the statement from another. You will see examples of this punctuation in later chapters.

Here's an interesting fact about Business Rules!: When you type in any command, you only have to type in the amount of letters to make the command unique. What this means is that commands, e.g. LET and SYSTEM, have shortened versions: LE (LET) and SY (SYSTEM). LET is the only command that starts with the letters "LE"; therefore, these are the only letters that you need to type in order to make the command unique and Business Rules! assumes that you mean LET. SYSTEM is the only command that starts with "SY", so typing "SY" makes the command unique and BR! assumes that you mean "SYSTEM". This useful shortcut can save you time. And if you're working with an experienced Business Rules! programmer and you notice him writing half-commands, you'll understand why. Here are the shortened versions of commands that you will learn later in the next chapter:

CL (CLEAR) Any letters after CL are optional.
RU (RUN) Any letters after RU are optional.
LIS (LIST) Any letters after LIS are optional.
SA (SAVE) Any letters after SA are optional.
LO (LOAD) Any letters after LO are optional.
REP (REPLACE) Any letters after REP are optional.

Lowercase VS Uppercase Letters

Business Rules! allows you to use either uppercase or lowercase letters when you type any command, statement or program. The system then takes what you have typed and automatically turns it into uppercase letters for you. (The exception to this is with literal expressions, which you will learn about in another chapter.) We encourage you to use whichever case (or a combination of both) that you are most comfortable with.

Quick Quiz 1.2

1) Choose the best description of a syntax sentence:

a) An example of an actual statement or command that can be typed in Business Rules!
b) A line that shows the general form and placement of items in a Business Rules! command or statement.
c) Line# LET variable = expression

2) All information that appears in capital letters in a syntax sentence must:
a) Be replaced with an item that fits the specific definition of this term.
b) Appear the same in the real command or statement as it does in the syntax sentence.
c) Separate one major portion of the statement from another.

Answers 1.2

NEXT: Basic Commands