• Keine Ergebnisse gefunden

Let's suppose that after checking the program we find that if the program returns to LINE 524 after it finishes its subroutine from LINE

Im Dokument North to (Seite 41-50)

523 it will not RUN. So all we have to do is add a GOTO statement so

that it dosen't come back to LINE 524. But wait, we've boxed

-29-ourselves in. There's not any numbers left that we can use to add a LINE at the required place. All we have to do is :

1. on READY type in REN 2. press RETURN key

3. on READY type in LIST

We will have to scroll through the program and look for the desired section that we are interested in since we do not know what the new LINE numbers are to LIST to. Let's say that we find them and the new numbers we want are 1150 to 1200. So we do the following:

and we get:

1. on READY type in LIST 1150,1200

1150 IF X

=

25 THEN 1180 1160 IF X

=

50-C THEN 1190 1170 IF 25

<

X

>

50 THEN 1200 1180 GOSUB 1550

1190 LET D = 22 1200 GO TO 80

Now we can add one LINE or up to nine additional LINEs after our GOSUB statement if we want to. Problem solved •••• Text on RENumber function ended.

8

HOW T 0 COR R E C TOR E D I T A P R 0 G RAM

I'm sure that the second thing that was done after the computer was worked out was to develop a system to correct programmer mistakes.

It must have been paramount in the mind of the people who developed the BASIC language, because there are so many different ways to correct the same mistake. Sometime you spend more time trying to decide which method of editing to use than if you just did the whole thing over. I shall discuss some of the most used methods.

If we have the following LINE in a program 130 IF A

=

B THEN 60 and you want to change it to:

130 IF A

=

B THEN 110 you do the following

1. on prompt or READY type in : EDIT 130

The EDIT command is a built in "function" which essentially treats the PROGRAM LINE that matches the LINE NUMBER after EDIT, as if it were the last thing typed into the computer.

2. on PROMPT press : CTRL key

&

G key

When you press the CTRL key and the G key together it is called a CONTROL- G . The CONTROL - G is a built-in edit "function" which automatically rePRINTS the last item that was typed into the computer.

Therefore you should get

130 IF A

=

B THEN 60

Now do a "shift-delete" by pressing the DEL key while holding down the SHIFT key. You will notice that each time you do a

"shift-delete" one character at the end of LINE 130 is erased. Since to make the desired change we need to erase the "60" we do the

"shift-delete" twice. Now that we have erased the "60", the prompt is in the proper position to type in the number "110". After you have typed in the "110" press the RETURN key. You have made the desired change To verify that the desired change was made, do a CONTROL-G, you

should get

130 IF A

=

B THEN 110

If there are no further corrections, press RETURN key.

Now let's make a change at the other end of the line, we want to change the LINE NUMBER 130 to LINE NUMBER 170.

1. on prompt or READY type in EDIT 130 2. press RETURN key

3. on prompt type in 170

4.

do a CONTROL-G

You have now made the desired change. If you want to confirm this do another CONTROL-G. You should get:

170 IF A

=

B THEN 110

And you do! However, you have left something behind. If you were to LIST your program you would find that you have LINE 170, as you just confirmed, and you would also see that LINE 130 didn't erase when you

"replaced" it. When you made all the other changes, one change automatically erased the thing it was changing. LINE NUMBERS are something special. If you want to do away with a LINE NUMBER you specifically have to tell the computer that. Here's how:

1. on prompt or READY type in 130 (LINE to be erased)

2. press RETURN key

The unwanted LINE 130 is now gone ..•

Now let's change:

170 IF A

=

B THEN 110 to

170 IF A

=

2*B THEN 110

Since the desired change this time is in the middle of the LINE, we can approach it from either end; it really dosn't matter. If the end results are the same, there is no "right" way. I will make the change starting from the LINE NUMBER side, you try it from the other

end:

-

-32-1. on prompt or READY type in : EDIT 170 2. press RETURN key

3.

on prompt press CTRL key and A key continue to do this until you have passed the "

= "

mark in your mark in your LINE

This is called a CONTROL-A. It is another "control function"

of the computer. It will automatically PRINT one character at a time - each time you press the A key while holding down the CTRL key -of the last thing typed into the computer or put in that "position" by an EDIT command.

4. Now press the CTRL key and the Y key

This is called a CONTROL-Y It is another "control function"

of the computer. It is also called the" insert control" It is a two step "control function". The first time you do a CONTROL-Y it will print a

"<"

at the start of the LINE position that you executed it. Such as :

170 IF A

= <

Then you type your desired change:

170 IF A

=

<2*

Then you do the second CONTROL-Y which will print the

">"

sign at the end of you insertion. You now have

170 IF A

=

<2*>

Then you do a CONTROL-G which prints the remainder of the line and you get :

170 IF A

=

<2*>B THEN 110

Then you do another CONTROL-G (This one is optional) and you get 170 IF A

=

2*B THEN 110

Which is exactly what we wanted.

There are at least two ways to delete characters from a prograr LINE. Again, both are commonly used and except under certiJ conditions, which one you use is up to you. Let's change LINE 170

from to:

170 IF A

=

2*B THEN 110 170 IF A

=

2 THEN 110

Method A

1. on prompt or READY type in: EDIT 170 2. do a CONTROL-A until the 2 appears

3.

press the "space bar" for each character

you want to delete. i.e .. two times

4.

do a CONTROL-G to display the remainder

of the line.

5. press RETURN key to effect the change and we get:

170 IF A

=

2 THEN 110

Which is what we wanted. However, look at all those wide open spaces. I have already told you that the computer dosen't care if they are there, so if you don't care then everything is fine. If you do care then I recommend Method B:

1. on prompt or READY type in: EDIT 170 2. do a CONTROL-A until the 2 appears

3.

press the CTRL key and the Z key for

each character you want omited. (two times)

This is called a CONTROL-Z. It is another editing "function"

of the computer. Each time you use it it will replace the character in that position with a

"%"

sign, until you are finished with all your changes and you enter the changes in the computer. When you LIST your change or do a CONTROL-G after you have EDITed, the omitted characters and the

"%"

sign are gone and so are the characters they replaced, and so is the "space" they occupied.

4.

do a CONTROL-G to complete the remainder of the line.

we get:

170 IF A =

2%%

THEN 110

5.

press RETURN key (this enters the change into the computer)

6.

do a CONTROL-G to see the EDITed LINE (optional)

we get:

170 IF A =

2

THEN 110 Which is exactly what we wanted.

-34-As to those conditions when i t is better to use the CONTROL-Z method of deletions as opposed to the "space bar" method of deletion, i t depends on how much space you can afford to use. Even though the computer essentially ignores excess spaces in LINE items, i t does not completely ignore them. It SAVEs them for you. If you put them there, i t assumes that you wanted them there. Every time i t SAVEs the

"blank space" i t also takes up one byte of memory. There are to my knowledge no "reserved words" or "commands" which have spaces in them.

Assuming that to be the case, all "spaces" could be eliminated from all programs. Thus our LINE 170 could be written:

170IFA=2THENIIO

The computer will handle this LINE 170 just as easy as the one above. Besides that, you would save 7 to 9 bytes on just that one LINE. Can you imagine the almost impossible task of trying to

"track" a three hundred LINE program written without any "spaces"

while looking for an error?

There are other EDIT "functions" in your system. By understanding those that I have written about, you are in a better position to evaluate the use of those I have not written about. Then you can decide whether they are worth the effort.

HOW T 0

operational programs), the "disc-reader".

The "disk-reader" is a wonderous machine. It can READ the

Im Dokument North to (Seite 41-50)