• Keine Ergebnisse gefunden

IF TYP(O) 2 THEN 60

Im Dokument North to (Seite 158-164)

Since the "part numbers" didn't match the computer will immediately go on to the next LINE. LINE 80 tells the computer that if the next thing to come up on the mini-disk is a numeric value then GOTO LINE 60. The way it tells the computer all of this is from the READ TYP function :

TYP(O)

( I shall go into greater detail in explaining the TYP function in another chapter. Suffice i t to say for the time being that it does what I have indicated that i t does.)

So what happens is that if N is not equal to P the computer goes back to LINE 60 and READs another set (RECORD) of variables. I t continues to do this until i t finds a set of variables (N and N$) where N

=

P, when i t finds N

=

P it then PRINTs the set (RECORD).

INPUT P READ N, N$

N<> P N P

PRINT N, N$

The next obvious question should be, " What happens if it doesn't find a match ? " Suppose that the INPUT number was never put into the data FILE, or the operator hit the wrong key and put in a "bad"

number --- what then ?

The first thing I can tell you is that if you didn't tell the computer what to do under these circumstances, it sure as hell doesn't know. Again, everything will come to a stop, or worse, the disk-reader will just keep running and running and running. I would suggest a CONTROL - C if this occurs.

You, as the programmer, must anticipate all the possible occurances, and write the program so that when they occur the computer knows what to do. To digress for a minute, I would like to relate a story I read in the newspaper which will illustrate my point.

In a state which allows personalized license plates for automobiles an enterprising computer programmer requested the license plate" NONE" . The agency which censors personalized plates saw nothing wrong with it, so the license plate" NONE"

was issued.

It did not become evident to the authorities why such a license plate should not have been issued, until about 20u unpaid parking tickets later.

It seems that whenever an unpaid parking ticket was turned over to the warrant division, they used their computer to match the name and address of the owner of the car with the license plates.

The computer was programmed such that if the license plate number was not a valid match, it would automatically give it the default "number"

" NONE ", thus making a match impossible.

Now, back to more important things. What to do if the computer can't make a match with our "part numbers" ?

Do this :

90 IF TYP(O)

o

THEN 150

This t e l l s the computer that i f the next thing up on the mini-disk is an END MARK, which would indicate END OF FILE, then the computer has gone through the entire FILE and has reached the END and still can not make a match. In that case the computer is instructed to GOTO LINE 150.

Which says

150 PRINT" THERE IS NO PART WITH THAT NUMBER ..

Then we start allover again, with:

-138-160 GOTO 50

Let's review our program up to this point 20

40 50 60 70 80 90 150 160

DIM N$(23)

OPEN

to,

"AUTOPART"

INPUT "WHAT IS THE PART READ

to,

N,N$

IF N

=

P THEN PRINT IF TYP(O)

=

2 THEN 60

IF TYP(O)

=

0 THEN 150

! "THERE IS NO PART WITH GOTO 50

NUMBER ", P N,N$

THAT NUMBER"

That is essentially the whole program. We have only two thing to add: 1. An escape statement. 2. CLOSE and END statements. Our

"escape" statement would be similar to the one we used in the preceeding chapter :

55 IF P

o

THEN 170 Such that when the computer ask you :

WHAT IS THE PART NUMBER and you type in

0

The computer will GOTO LINE 170 , which says 170 CLOSE 10

and then 180 END

Th~t's all there is to it •••••••••

31

HOW T 0 COP Y A D A T A F I L E

FRO M 0 N E MIN I - DIS K T 0 A NOT HER

There is no real problem with transfering a TYpe 3 data FILE from one mini--disk to another, it just has to be done by some method other than the LOAD and SAVE method used for programs written in BASIC, i.e.

TYpe 2 FILEs.

Essentially, what you must do is ReaD a specific number of blocks of data at a specific starting place (ADDRESS) on the mini-disk into the computer, then put in the "new" mini-disk and WRite the same data to a specific Disk Address.

This method can be used to completely copy anything that is on one mini-disk to another, not limited only to TYpe 3 FILEs. You alternately ReaD a specific number of blocks into the computer's memory (number of blocks dependent on available memory) from the "old"

mini-disk, and then WRite them out of the computer's memory at a specific Disk Address on the "new" mini-disk.

Here is how to do it for a TYpe 3 FILE :

1. Put the computer in the DOS mode.

a. From start up type in : EX E900 b. From BASIC on READY type in : BYE

2. Put the mini-disk with the TYpe 3 FILE to be transfered in the disk-reader.

3. on

*

type in : LI

Let's suppose that the FILE that we intend to copy is named CUSTOMER and it is 50 blocks long. When we LIst we get:

CUSTOMER 4 50 3

Which indicates that the FILE name is CUSTOMER, i t starts at block 4 (disk-address), i t is

50 blocks long, and it is a TYpe 3 FILE.

4. Now.put the "new" INITIALIZEd mini-disk into the disk-reader and CReate a FILE named CUSTOMER that is 50 blocks long.

To do this you

on

*

type in : CR CUSTOMER 50

5. We must tell the computer that the FILE with the name CUSTOMER is a TYpe 3 data FILE. You then :

on

*

type in : TY CUSTOMER 3

6. So that we know where to tell the computer to WRite the stored data it got from ReaDing the

"old" mini-disk, we need to know the Disk Address of the FILE named CUSTOMER on the "new" mirii-disk To find that out we :

on

*

type in LI

We get

CUSTOMER 135 50 3

7. Let's stop and recap what we've done and what we want to do. First look at the Disk Address :

"old" CUSTOMER 4 50 3

"new" CUSTOMER 135 50 3

We want the computer to ReaD 50 blocks of data from the "old" FILE named CUSTOMER starting at Disk Address 4 and store it in it~ "regular"

memory ( READ,WRITE,LOAD,SAVE, and program portion of the memory). So that's what we tell i t :

on *

type in

RD

4

2AOO

50

Im Dokument North to (Seite 158-164)