Custom Search
 
  

 
Correcting Mistakes

At one time or another, we all make mistakes when were keying in statements. For that reason, ways are provided for you to make corrections. These may vary depending on the computer youre using. On many computers, the statements you key in are not sent to the interpreter until you have depressed the RETURN key. Should you make a mistake in a statement before you have depressed the return key, you can backspace with the backspace key and key the correct information.

For example:

you typed

but you intended to type an asterisk (multiply) instead of a plus sign (addition). You can correct it by backspacing once and keying the correct information. The * (asterisk) will replace the + (plus), then you continue by keying the rest of the statement.

Should you make more than one mistake in a line, use one backspace for each character you want to erase or replace.

If you make a mistake in a statement and you have already entered the statement, you will have to correct it in another way. The following examples show how it can be done.

Suppose you had entered the following program:

Lines 10 and 70 contain errors. You can correct them by simply retyping the lines as they should be.

These will overlay (replace) the original lines 10 and 70. If you list or display your program after making these changes, it will appear as follows:

Lines 10 and 70 which were originally entered incorrectly were replaced by the retyped lines and are in correct form and in proper sequence in the program. As we stated earlier, duplicate line numbers are not allowed and the second statement entered with the same line number will overlay or replace the first.

Some computers have an EDIT/RECALL feature which allows you to enter the line number you want to correct and then depress EDIT/RECALL. It will display this line on the screen and allow you to make changes to it. You may also delete a line by typing the command DELETE and the line number, for example:

This will delete line 50.

Another way to delete a line is to type in only the line number and depress the RETURN key, for example:

    50

This will also delete line 50.

When you are keying in your program, some computers will check for syntax errors as each statement is entered. Others will check for syntax errors when you enter the system command RUN. In either case, you11 get an error message indicating where there is a syntax error. (See the following example.) These errors must be corrected before the program can be executed.

Look at line 60, find the error. The )Y is incorrect; the ) should not be there. Now that you know what the error is, you can use one of the methods discussed to correct it and try again.

Unfortunately, at this stage, the computer can only find syntax errors, it cannot determine if you have made a logic error. Logic errors will be found when you try to run the program during debugging and testing.

To help find logic errors, you may find it useful to include some documentation about the program within it. To do this, you use the REMARK statement.







Western Governors University
 


Privacy Statement - Copyright Information. - Contact Us

Integrated Publishing, Inc. - A (SDVOSB) Service Disabled Veteran Owned Small Business