• Keine Ergebnisse gefunden

PRINT TS(C) 40 NEXT C

Im Dokument North to (Seite 138-142)

CDEFGH DEFGH EFGH

10 B$ = "ABCDEFGH"

20 FOR E = 1 TO 3 30 FOR F = 3 TO 6 40. PRINT B$ (E,F) 50 NEXT F

60 NEXT E

ABC BCD CDE

20 ! " 11M THINKING OF A WORD - WHAT IS IT "

30 INPUT "TYPE IN A THREE LETTER WORD ",B$

40 FOR X = 1 TO 3

50 IF B$(X,X)=A$(X,X) THEN !"CORRECT ",B$(X,X) 60 NEXT X

70

80 IF B$=A$ THEN

1"****

YOU ARE RIGHT

****"

85

90 IF A$

< >.

BS THEN 30 95 GOTO 10

100 DATA "CAT","DOG","PUT","TAP","COY","MIX","WRY"

This program compares each character of the INPUT word (B$) with each character of the "game word" (A$). If the computer makes a match, then the character is printed. If the computer does not make a match, i t goes on to the next character and repeats the process.

After i t has evaluated all three characters (letters), i t then evaluates the word. If i t makes a match, it tells you so, and then READs a new "game word". If it does not make a match, the computer returns to the INPUT statement for you to try another word.

The above explanation and sample programs will only give you a start on the use of SUBSTRINGS. Learning how to use them well will widen your available choices to compare data. A good deal of the use of the computer is to compare data, the more ways you know how to do it, the more use you will get out of the computer.

That is NOT all there is to know about that •••••

28

SEQ U E N T I A L F I L E S

To get the maximum use of your system i t is mandatory to learn how to use data FILEs (TYpe 3 FILEs), and be familiar with how they work and how the computer READs and WRITEs to them. Any time you use (access) a data FILE you are storing data on a device and therefore are leaving FREE available memory in you computer for writing or expanding your program. You are also able to store data far beyond the memory capacity of your system, since each mini-disk will store about 90,000 bytes (90 K). As mentioned earlier, each mini-disk contains 350 blocks and each block contains 256 bytes.

Before getting into the specifics of how data FILEs work, a general over-all view of their operation will show that they are not

too different from any other TYpe FILE. TYpe 3 data FILEs, like all other TYpe FILEs, must first be CReated. In order to do that they must be named. The same rules for naming other TYpes of FILEs apply for naming TYpe 3 FILEs. The next step is to TYpe the FILE, all DATA FILEs are TYpe 3 • That means that they can only be used (accessed) by a READ or WRITE statment in a BASIC program. Having done all the above, the FILE is ready for putting in data.

To add data to a FILE one usually writes a program that asks for specific information to be typed in (INPUT). Once the required information is supplied, the computer is then told to WRITE this information (data) onto the mini-disk. Each new addition is added to the mini-disk immediatly fo~lowing the previous data, thus a sequential FILE is slowly filled with data. The required information may be no more than a single numerical value or may be more than a

thousand numbers or words, depending on the program written to add (WRITE) data to the FILE. Regardless of the INPUT the computer essentially handles it all in the same manner, and records (WRITEs) it on the mini-disk the same way.

Just having a' mini-disk full of information is not of much value.

It only becomes valuable when one can ask for a specific piece of data and the computer in its unique way can search all that available information and then give you what you ask for, if it has it, in a matter of seconds. In order to be able to do this, you must now write a second program - this time to take out information (READ).

Having learned how to do all the above, you have greatly expanded the capacity of your system and increased it's range of usefulness.

Now let's learn how to do all the above.

First we must again remember that the computer does no more than what one could do himself by conventional methods. It has a couple of advantages over doing the task by "hand". Number one, it can search a FILE much faster. It essentially does i t by the same method that you would, i t looks at all the data until it finds some that matches what i t is looking for.

Number two, the computer can evaluate the "found" data for any number of instructed conditions, such as: IF this is found - do this, or IF this is equal to that - do this, and so on.

The computer can perform all of these task in a matter of seconds, usually with little or no error. The human can perform all of these tasks by "hand", hopefully with little or no error. The main difference between the two methods is time and efficiency.

We will approach the use of DATA FILEs on the basis of contrasting the "hand" method with the "electronic" method. This will allow the reader to better understand what is happening, and be able to relate to the sequence of events.

Let's suppose that you work for an auto parts supply company.

You have been given the job of preparing an inventory listing of all auto parts and assigning a part number to each. This information is to be placed in a file and stored for future use.

You start by first getting a file folder and naming the folder AUTO PARTS. You then get some paper and start recording the part number with its accompanying auto part. You start at the top of the page and continue to add part number, then part name. You continue this procedure until you have finihed the task. You then put the papers in the file folder and then put the file folder into a file cabinet.

Using our above example, the "electronic" method would be essentially the same. First, we must CReate a file folder. We do this by the following.

1. We must put the computer into the DOS mode.

a. From start up - put a mini-disk with Disk Operating System (DOS) on i t in the disk-reader.

on

>

type in EX E900

b. From BASIC mode

on READY type in BYE

-121-2. To CReate our "file folder" , with the name AUTOPART, we must place an INITIALIZEd mini-disk in the disk-reader and then:

on

*

type in CR AUTOPART 300

This CReates a FILE with the name AUTO PART which is 300 blocks long - which is almost the capacity of a new mini-disk.

3. We must then tell the computer that the FILE named AUTO PART is a TYpe 3 data FILE, so that we will be able to READ and WRITE to the FILE. This is accomplished by:

on

*

type -in : TY AUTOPART 3

We now have a "file folder" labeled AUTOPART, it is ready to put our RECORDs into it.

Next we want to develop a data FILE which contains two pieces of information for every auto part maintained in the inventory of a parts house. We want to give every auto part a part number, and then we want to identify the auto part which goes with this number. We want to WRITE this inforamtion in an orderly manner, as was done by the

"hand" method above.

Our first step is to write a program which will add this information to our FILE in an orderly manner. There are two questions that the computer must a3k : 1. "WHAT IS THE PART NUMBER ", 2. "WHAT IS THE PART NAME".

In BASIC these questions are represented by the INPUT statement as

Im Dokument North to (Seite 138-142)