Custom Search
 
  

 
CHAPTER 7

STORING AND RETRIEVING PROGRAMS AND DATA

Up to this point, we have dealt with reading data, using READ and DATA statements, inputting data, using the INPUT statement, and printing output. We have not discussed storing and retrieving programs or storing and retrieving data. It seems useless to write a program, key it in, get it to work, and then be unable to save it to run again later without keying it in again. As you write programs to solve more complex problems with large amounts of data, youll need ways to save your programs and data on some type of storage medium. You will probably use a magnetic disk or tape.

The way this is done varies considerably from one computer to another. Therefore, we will not attempt to present all the possible ways. The primary concern is that you are aware that there are ways to store and retrieve both programs and data. Your computer users reference manual will provide you with detailed instructions.

STORING AND RETRIEVING PROGRAMS

First, lets examine one method for storing a program. When storing a program, you must have a way to reference it in order to load it to be run again. To do this, you assign it a name. Program names are a series of characters you choose. Depending on the computer you are using, you will probably be limited to six or eight characters. There may also be limitations on specific characters that can be used. Most computers require the first character in a program name to be alphabetic.

If you are using a computer which has more than one programming language available, you will have to specify the programming language you wish to use. The following example shows how this might be done.

Example:

In the first line of the example, the computer asks what programming language you want to use by displaying the word, SYSTEM. You enter BASIC; then it asks if you want to retrieve an OLD program or enter a NEW one. You enter NEW. The computer then asks for the NEW FILE NAME; you enter MPG as the program name. The computer then responds with the message, READY. This indicates the computer is ready for you to key in your program. You key in your program in the same manner as you have throughout this course.

Once you have entered the program, you key in the system command, SAVE, which instructs the computer to store your program either on disk or tape. The computer then responds with the message, FILE MPG SAVED. To recall a saved program, you respond with OLD to the computer query NEW or OLD. The computer will then ask for the program name. After you have entered the program name, the computer loads the program into memory. It is then available to be executed, changed, or listed.

To SAVE a program on some computers, all that is required is to key in the program, enter the system command, SAVE, followed by the program name enclosed in quotation marks.

Example:

This command will save the program.







Western Governors University
 


Privacy Statement - Copyright Information. - Contact Us

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