JES: Just Educational Services

Jonathan E. Sisk's
Pick/BASIC: A Programmer's Guide

Chapter 12 - An Introduction to File I/O

Click to enlarge

There are three main operations that programs perform: input, process, and output. Up to this point, the examples have demonstrated various techniques for processing data and directing the output to the screen or printer. Data may also be output to a file, or input from a file. This is commonly called file input and file output--or more simply, "file I/O". Data items from a file are input to a program, processed (modified), and output to a file.

The Pick System offers several methods of processing data items within programs. Dynamic arrays are perhaps the easiest and most straightforward approach to manipulating and storing items in a file.

In order to get the full benefit of this discussion, enter the example program in Fig. 12-1 before proceeding to the explanations of the new topics covered. Before executing the program, create the STAFF file. The data items from Appendix B must be present in the file.


Fig. 12-1. Program Example 10.

001 * EX.010
002 * File Input and Dynamic Arrays
003 * mm/dd/yy: date last modified
004 * JES: author's initials
005 *
006    PROMPT ":"
007 *
008    STAFF.ITEM = ""   ; * INITIALIZE STAFF ARRAY
009 *
010    OPEN "STAFF" TO STAFF.FILE ELSE STOP 201,"STAFF"
011 *
012 LOOP
013   PRINT "ENTER STAFF NUMBER TO DISPLAY OR 'QUIT' TO STOP" :
014   INPUT STAFF.ID
015 UNTIL STAFF.ID = "QUIT" DO
016   READ STAFF.ITEM FROM STAFF.FILE,STAFF.ID THEN
017     PRINT
018     PRINT "NAME"        "L#16" : STAFF.ITEM<1>
019     PRINT "ADDRESS1"    "L#16" : STAFF.ITEM<2,1>
020     PRINT "ADDRESS2"    "L#16" : STAFF.ITEM<2,2>
021     PRINT "CITY"        "L#16" : STAFF.ITEM<3>
022     PRINT "STATE"       "L#16" : STAFF. ITEM<4>
023     PRINT "ZIP"         "L#16" : STAFF.ITEM<5>
024     PRINT "HIRE DATE"   "L#16" : OCONV(STAFF.ITEM<7>,"D2-")
025     PRINT "HOURLY RATE" "L#16" : OCONV(STAFF.ITEM<9>,"MR2,$")
026     PRINT
027   END ELSE
028     PRINT
029     PRINT "ITEM" : STAFF.ID : "NOT FOUND."
030   END
031 REPEAT
032 *
033 END

HANDLING FILES: THE OPEN STATEMENT

Before items may be read from or written to a file, the file must be opened:

010 OPEN "STAFF" TO STAFF.FILE ELSE STOP 201,"STAFF"

Opening the file simply means that the operating system must establish a connection to the physical location of the file on the disk. The OPEN statement directs the system to establish this connection automatically. Line 10 opens the file.

The general form of the OPEN statement is:

OPEN "filename" TO filevariable {THEN...} ELSE . . .

The filename argument typically is enclosed in quotes, in which case the filename must be spelled exactly as it is found in the MD of the current account. The filename also may be contained in a variable, with the same exact spelling restrictions. The TO filevariable specification is optional, but recommended. The file variable is the name by which the file will be referred to throughout the rest of the program for all subsequent READ and WRITE statements.

Not assigning the opened file to a file variable is called "opening the file as the default file variable." Using the default file variable form is a shortcut that affects subsequent READ and WRITE operations. Normally, each READ and WRITE statement includes the file variable from which the item is to be mad or to which the item is to be written. In the default file variable form, the file variable does not have to be specified. This technique is acceptable when only one file is being used.

The THEN initiator is allowed, but not required. Any statement, or statements, following the THEN initiator are executed when filename is found in the MD of the current account. The ELSE clause is required. Any statements following the ELSE clause are executed when the filename is not found in the current MD. Usually, the code after ELSE advises the user that filename was not found and terminates the program.

Error Message Numbers with the STOP Statement

In earlier examples of the STOP statement, it most often was used in an IF-THEN or an IF-THEN-ELSE construct. None of these examples particularly required any subsequent explanation of the reason why the program was stopped, since it was most likely terminated voluntarily.

In this example, however, the STOP statement is followed by the item-id "201."

010 OPEN "STAFF" TO STAFF.FILE ELSE STOP 201,"STAFF"

This extension to the STOP statement allows any error message from the ERRMSG file to be displayed upon execution of the STOP statement. This message happened to be error message 201, which, if examined, appears as follows:

Filename: ERRMSG
Item-id : 201
     001 '
     002 A
     003 H' IS NOT A FILE NAME

Upon activation of this error message, the literal "STAFF" is inserted ("passed' ') into the text of the message where the letter A appears. This means that if this executes, it displays:

'STAFF' IS NOT A FILE NAME

STOP vs. ABORT

The error message extension also applies to the ABORT statement. The difference between the STOP and ABORT statements is that the STOP statement terminates a program, but if the program had been activated from a PROC, the PROC will not be terminated.

The ABORT statement terminates the program and any PROC from which it may have been activated.

For instance, suppose this program had been activated from a PROC menu--a very common situation. Normally the PROC menu clears the screen and offers a number of different menu options. If this program executed the STOP statement and displayed the error message about the file not being found, and then control returned to the menu, the message would display so quickly on the screen that it could be noticed only by graduates of speed- reading classes.

On the other hand, if the STOP statement had been replaced with the ABORT statement, the message would display on the screen and the program and menu would be terminated. The disadvantage of the ABORT statement is that the bewildered operator is left at the TCL prompt. That's when the programmer gets the phone call announcing that something is wrong with the program. One frequent cause of this problem is that the program is being run from the wrong account.

One popular method of tackling this problem is by adding a few lines of code to the ELSE clause that issues the STOP statement. For example:

OPEN "STAFF" TO STAFF.FILE ELSE
  PRINT "STAFF IS NOT A FILENAME!" :
  INPUT RESPONSE
  STOP
END

This technique is not quite as slick as using the error message extension illustrated in Example 10, but it has the added advantage of pausing the program long enough to advise the operator about the error condition and awaiting their response.

Some programmers prefer to keep the operators on their toes by putting the message up on the screen for a certain amount of time. This involves the use of the SLEEP statement, as illustrated in the following example:

OPEN "STAFF" TO STAFF.FILE ELSE
  PRINT "STAFF IS NOT A FILENAME!" :
  SLEEP 5
  STOP
END

When this code is executed, and the ELSE clause is executed, the message appears on the screen for 5 seconds before resuming the menu. For added fun, the number of seconds may be randomized, so that the program's naptime varies each time it is executed. (Operators tend to not find this technique amusing.)

OBTAINING THE ITEM-ID

Before reading an item from a file, the item-id must be obtained. There are a number of methods of obtaining the item-id. This particular method prompts the operator to enter it:

013 PRINT "ENTER STAFF NUMBER TO DISPLAY OR 'QUIT' TO STOP" :
014 INPUT STAFF.ID

Use one of the data items from the STAFF file for this example. This program stores the item-id in the variable STAFF.ID.

READING DYNAMIC ARRAYS FROM FILES

An array is a data structure which contains multiple data elements. Each element may be referenced by a numeric subscript, which indicates its position in the array. A dynamic array is generally used to hold an item (record) while it is being processed in a PICK/BASIC program.

Once the item-id is entered, and after checking the response to see if the operator wants to quit, the item may be read from the file and placed into the dynamic array.

The READ statement is used to retrieve an item from a file. It has the following general format:

READ array.variable FROM file.variable,id.expression . . .
 · . . {THEN statement(s)} ELSE statement(s)

Like the OPEN statement, the THEN clause is optional in a READ statement, and the ELSE clause is required. The statement, or statements, following the ELSE clause instruct the program how to behave if the requested item-id is not found.

In Example 10, both the THEN and the ELSE initiators were used (Fig. 12-2). Line 16 performs the READ statement. If the item-id is found, the statements from lines 17 through 26 are executed. These statements display some of the attributes from the item. After line 26 is executed, control returns to the top of the loop, where the operator is again prompted to enter an item-id.


016 READ STAFF.ITEM FROM STAFF.FILE,STAFF.ID THEN
017   PRINT
018   PRINT "NAME"          "L#16" : STAFF.ITEM<1>
019   PRINT "ADDRESS1"      "L#16": STAFF.ITEM<2,1>
020   PRINT "ADDRESS2"      "L#16" : STAFF.ITEM<2,2>
021   PRINT "CITY"          "L#16": STAFF.ITEM<3>
022   PRINT "STATE"         "L#16" : STAFF.ITEM<4>
023   PRINT "ZIP"           "L#16" : STAFF.ITEM<5>
024   PRINT "HIRE DATE"     "L#16" : OCONV(STAFF.ITEM<7>,"D2-")
025   PRINT "HOURLY RATE"   "L#16" : OCONV(STAFF.ITEM<9>,"MR2,$")
026   PRINT
027 END ELSE
028   PRINT
029   PRINT "ITEM" : STAFF.ID : "NOT FOUND."
030 END

Fig. 12-2. The THEN and ELSE clauses in the READ statement.



ENTER STAFF NUMBER TO DISPLAY OR 'QUIT' TO STOP :100<cr>

NAME               THOMPSON, HUNTER
ADDRESS1           C/O STARDUST HOTEL
ADDRESS2
CITY               LAS VEGAS
STATE              NV
ZIP                77777
HIRE DATE          05-01-92
HOURLY RATE        $150.00

Fig. 12-3. Sample output from Program Example 10.


If the item-id is not found, then the statements after the ELSE clause on line 27 are executed. Line 28 issues a blank line on the screen, and line 29 advises the operator that the just-entered item-id was not found. Execution then passes back to the top of the loop. Suppose you entered the item-id 100, and you had entered the data from the sample data in Appendix B. The information shown in Fig. 12-3 then displays on the screen:

REFERENCING DYNAMIC ARRAYS

In referring to any element within a dynamic array, such as STAFF.ITEM in our example (Fig. 12-4), the angle brackets < and > are used to specify subscript locations. A subscript is simply a number that corresponds to an attribute, value, or subvalue location within an array. Dynamic arrays may be referenced in several different ways.

Referencing Attributes with Array Reference Symbols

The general syntax for referencing attributes with array reference symbols is: array.variable<amc.expression >


018   PRINT "NAME"          "L#16" : STAFF.ITEM<1>
019   PRINT "ADDRESS1"      "L#16": STAFF.ITEM<2,1>
020   PRINT "ADDRESS2"      "L#16" : STAFF.ITEM<2,2>
021   PRINT "CITY"          "L#16": STAFF.ITEM<3>
022   PRINT "STATE"         "L#16" : STAFF.ITEM<4>
023   PRINT "ZIP"           "L#16" : STAFF.ITEM<5>
024   PRINT "HIRE DATE"     "L#16" : OCONV(STAFF.ITEM<7>,"D2-")
025   PRINT "HOURLY RATE"   "L#16" : OCONV(STAFF.ITEM<9>,"MR2,$")

Fig. 12-4. Referencing the fields of the STAFF.ITEM dynamic array.


The amc.expression is a number which refers to the Attribute Mark Count (AMC). For example:

018 PRINT "NAME"	"L#16" : STAFF.ITEM<1>

This displays the literal "NAME," left-justified in a field of 16 spaces, and then outputs the entire contents of attribute 1.

Referencing with the EXTRACT Function

Before the dynamic array reference symbols were added to the Pick/BASIC language, locations from within a dynamic array were extracted using the intrinsic function EXTRACT. This function has the general format:

EXTRACT(array.variable,amc.expression,vmc.expression,svmc.expression) 

Line 18 could have been replaced with the statement:

018 PRINT "NAME"  "L#16": EXTRACT(STAFF.ITEM,1,0,0)

This produces the same result as using the dynamic array reference symbols. The manner you choose to retrieve locations from dynamic arrays is up to you. There is not a great deal of difference in execution efficiency between the two methods. Additionally, both methods are fully implemented across all implementations of Pick, so compatibility is not an issue.

One consideration of the dynamic array reference symbols versus the EXTRACT function is that the EXTRACT function needs a little more code, due to syntax requirements. The general format of the EXTRACT function requires all four of the arguments within the parentheses. This is how the function was originally designed to be used. As you recall, in the previous illustration the code read:

... EXTRACT(STAFF.ITEM,1,0,0)

Zero (0) was substituted for the vmc.expression and svmc.expression, since they are required by the syntax of the EXTRACT function.

Referencing Values

The general syntax for referencing values is: array.variable < amc.expression, vmc.expression >

The vmc.expression derives a number which refers to the Value Mark Count (VMC) within an attribute. For example:

019 PRINT "ADDRESS1"      "L#16" : STAFF.ITEM<2,1>

This displays the literal "ADDRESS1," left-justified in a field of 16 spaces, and then outputs the contents of the first value in the second attribute.

The dynamic array reference symbol form of this instruction has an alternative in the EXTRACT function. Line 19 also could have been replaced with the statement:

019 PRINT "ADDRESS1"     "L#16": EXTRACT(STAFF.ITEM,2,1,0)

Referencing Subvalues

Expressions referencing subvalues have the following general form:

array.variable<amc.expression,vmc.expression,svmc.expression> 

The svmc.expression derives a number which refers to the Subvalue Mark Count (SVMC) within a value.

A subvalue also may be retrieved with the EXTRACT function using the same general format as illustrated before:

EXTRACT(array.variable,amc.expression,vmc.expression,svmc.expression)

THE "LOGICAL" AND "PHYSICAL" VIEWS OF DATA

The way you see data within a process such as the Editor is not at all the way the operating system sees it. For the most part, this is not particularly important and will remain transparent to the majority of the people who actually use the system. For you, as the programmer, it is important to know how the system deals with data.

For example, take an array called CUSTOMER.ITEM, which, in its "logical" view, looks like this:


ITEM-ID:  100
Attribute Content
      001 YUPPIE HAVEN RESORT
      002 PO BOX 7]ROUTE 17
      003 BEDFORD
      004 VA
      005 24505

This is its "logical" form, because this is how it is typically displayed by the Editor, with the line numbers on the left corresponding to attribute mark numbers.

The "physical" form, on the other hand is the way the item is actually handled and stored by the operating system:

100^YUPPIE HAVEN RESORT^RD BOX 7]ROUTE 17^BEDFORD^VA^24505^ 

To the program, a dynamic array simply appears as one long string of characters, delimited by attribute marks (^), value marks (]), and occasionally, subvalue marks (\), which are not shown in this example.

Since the system treats dynamic arrays as string variables, if the statement:

PRINT CUSTOMER.ITEM

were issued, the entire item displays, along with all of its embedded delimiters-the attribute, value, and subvalue marks.

Important note: Any time that any of the reserved delimiters are displayed by a PICK/BASIC program, a metamorphosis occurs. This is due to the fact the PICK/BASIC strips the high-order bit on characters above decimal 128. The program thus subtracts 128 from the actual decimal value of the delimiter and prints the corresponding character. This means that the attribute mark, which normally displays as a caret(^), appears when printed by a PICK/basic program as a "tilde" (~). Value marks, which normally appear as a bracket (]) appear as a brace ( } ). And finally, subvalue marks which normally appear as a (\), appear as a vertical bar ( | ).

Normally, the entire item is not printed in one PRINT statement, since the display of the extra characters which serve as delimiters might be confusing. Rather, specific locations, such as an attribute or value locations, are requested, as in either of the following statements:

PRINT CUSTOMER.ITEM<1>

or

PRINT EXTRACT (CUSTOMER.ITEM,1,0,0)

This prints the contents of the first attribute. Using the physical view of our item, the following displays on the screen:

YUPPIE HAVEN RESORT

If an attribute or value contains multiple values or subvales, then additional specifications are added to the syntax, as in the follwing examples:

PRINT CUSTOMER.ITEM<2,1>

or

PRINT EXTRACT (CUSTOMER.ITEM,2,1,0)

Again, using the same item, this displays

P.O. BOX 7

These statements both instructed the program to print the first value from attribute two.

To retrieve the second attribute, either of the following two statements may be issued:

PRINT CUSTOMER.ITEM,<2,2.>

or

PRINT EXTRACT(CUSTOMER.ITEM,2,2,0)

Finally, a specification to reference subvaluews may be added. Using the sample data and instruction shown in FIG. 12-5, we can print the third subvalue from the second value of the first attribute. From this example, the display is "789."

The alternate instruction that could have been used in Fig. 12-5 is:

PRINT EXTRACT (INVOICE.ITEM,1,2,3)

WHY DYNAMIC ARRAYS NEED TO BE REFERENCED

Now that you have seen how to reference a location, you now need to know why you want to. Dynamic array references are used in two ways. First, as in Example 10,



Array name : INVOICE.ITEM
Item-id :    S1000
      001 X456]123\456\789 

Physical view:

S1000^X456]123\456\789^_

instruction:

PRINT INVOICE.ITEM<1,2,3>

FIG 12-5. A LOGICAL DATA VIEW WITH VALUES AND SUBVALUES


they were used to output values to the screen or printer. Second, in some cases they may be used in an assignment statement. This means that they appear on the left side of a "=" symbol, like in the following example:

001 PRINT "ENTER NAME" :
002 INPUT NAME
003 IF NAME = "QUIT" THEN STOP
004 CUSTOMER.ITEM<l> = NAME

Line 1 prompts the operator to enter a name, which is assigned to the variable NAME on line 2. Line 3 checks to see if the operator wanted to quit, in which case the STOP statement is issued. If not quitting is chosen, then line 4 assigns the response to attribute "one" of the array CUSTOMER.ITEM.

While this appears to be a rather simple means of dealing with a dynamic array, there are some sneaky side effects and further implications to be discussed.

SNEAKY SIDE EFFECTS OF DYNAMIC ARRAYS

In the next example, four special intrinsic functions are discussed. These are INSERT, REPLACE, DELETE, and LOCATE. They are used to manipulate dynamic arrays and were the first methods available for this purpose. The alternate array reference symbols < and > came later to the language.

The INSERT statement is used to add a new value at a specified subscript location in an array. It does exactly what it is told to do. This means that if you INSERT a string into attribute one, then it "pushes" down any existing attributes by one attribute.

The REPLACE statement, on the other hand, replaces the contents of any subscript location. If there is no value in the specified subscript location, the REPLACE statement adds all of the necessary delimiters to accommodate the request; in this case, it acts like the INSERT function.

The dynamic array references in an assignment statement are nearly as ambiguous. Confused? Relax. So was I at first. If you follow some simple guidelines, this gets to be quite easy.

When a dynamic array reference appears on the left side of an equal symbol, it may be interpreted as either an INSERT or a REPLACE function, depending on the existing contents of the array. For instance, suppose an array variable called VENDOR.ITEM, is currently empty, as in this example:

001 VENDOR.ITEM = ""
002 PRINT "ENTER VENDOR CITY" :
003 INPUT CITY
004 IF CITY = "QUIT" THEN STOP
005 VENDOR.ITEM<3> = CITY

Further suppose that you enter "BATON ROUGE" as the response and the array is displayed with the statement:

006    PRINT VENDOR.ITEM

The following appears on the screen:

~~BATON ROUGE

(Remember the "metamorphosis" note pertaining to the conversion of the delimiters when printed by a program.)

In this case, the dynamic array reference on line 5 is treated as an INSERT function. Since none of the attribute marks are already in place, the program inserted two attribute marks before the string "BATON ROUGE" to accommodate your request.

On the other hand, assume that an array had already been constructed, and appeared as follows (in its logical view):


Array Name : VENDOR.ITEM
Item-id    : 1000
001 U.S. COPYRIGHT OFFICE
002 LIBRARY OF CONGRESS
003 WASHINGTON
004 DC
005 20001

Suppose the following code were executed:

001 PRINT "ENTER VENDOR CITY" :
002 INPUT CITY
003 IF CITY = "QUIT" THEN STOP
004 VENDOR.ITEM<3> = CITY

and the response entered was "NEW YORK." Here's how the array appears after the execution of line 4:

001 U.S. COPYRIGHT OFFICE
002 LIBRARY OF CONGRESS
003 NEW YORK
004 DC
005 20001

In this case, the dynamic array reference on line 4 is treated as a REPLACE function. Since all of the attribute marks are already in place, the program did not have to insert any attribute marks before the string, "NEW YORK," to accommodate the request.

The implication of what you have just seen is that you basically need to know, with reasonable accuracy, just what you want to do to an array, based on whether the structure is already in place. If the array is not already in place, then the INSERT or REPLACE functions may be used to put strings into specific locations. If the array is in place, then the REPLACE function may be used to exchange the contents of any subscript location.

SPECIAL ARGUMENTS IN DYNAMIC ARRAY REFERENCES

In the previous illustrations of referring to subscripts within a dynamic array, each numeric expression within the array reference symbols < and > evaluate to positive numbers which corresponded to attribute, value, and subvalue locations.

A "-1" argument may be used in place of any of the numeric expressions within the dynamic array reference symbols to force the position index to the end of the appropriate array location. For instance, suppose the following statements were executed:

001 WORK.ITEM = ""
002 WORK.ITEM<-1> = "ATTRIBUTE ONE"
003 WORK.ITEM<-1> = "ATTRIBUTE TWO"
004 WORK.ITEM<-1> = "ATTRIBUTE THREE"
005 PRINT WORK.ITEM

Line 1 initializes the dynamic array WORK.ITEM. Line 2 inserts a new attribute at the end of the otherwise "null" array. This effectively creates attribute one. Similarly, line 3 also adds a new attribute to the end of the array, which results in the literal "ATTRIBUTE TWO" being placed into attribute two. Line 4 does the same thing yet again, putting the string "ATTRIBUTE THREE" into attribute three.

When line 5 is executed, the following appears:

ATTRIBUTE ONE~ATTRIBUTE TWO~ATTRIBUTE THREE

This approach to dealing with arrays is, at best, highly unconventional. More realistically, the "- 1" argument is used to add a new value at the end of a multivalued attribute, or to add a new subvalue to the end of a value which may need to contain subvalues. The example in Fig. 12-6 illustrates this principle.

Line 1 initializes the array CUSTOMER.ITEM. On line 2, the operator is prompted to enter the first line of the address, which is stored in the variable RESPONSE on line 3. Line 4 checks to see if he or she wants to quit. Line 5 adds the response to the end of attribute two. As a result, the array now has two attributes, the second of which has one value.

This logic is repeated in lines 6 through 8 and on line 9, the second line of the address is added to the end of attribute two. After execution of line 9, the array has two attributes, the second of which contains two values. These two values are displayed on lines 10 and 11.

CHOOSING THE ITEM-ID

Each item-id in the Pick System is hashed to determine the group in which it will reside. The process of hashing effectively takes each character in the item-id and converts it to its decimal equivalent. The result of each of these decimal conversions are added together to form the hash total. This hash total is then divided by the modulo of the file, which is the number that indicates the number of groups in a file. The remainder of this division is then added to the base fid of the file, and that effectively becomes the group to which the item hashes.


001 CUSTOMER.ITEM = ""
002 PRINT "ENTER ADDRESS LINE 1" :
003 INPUT RESPONSE
004 IF RESPONSE = "QUIT" THEN STOP
005 CUSTOMER.ITEM<2,-1> = RESPONSE
006 PRINT "ENTER ADDRESS LINE 2" :
007 INPUT RESPONSE
008 IF RESPONSE = "QUIT" THEN STOP
009 CUSTOMER.ITEM<2,-1> = RESPONSE
010 PRINT "ADDRESS 1 : " : CUSTOMER.ITEM<2,1>
011 PRINT "ADDRESS 2 : " : CUSTOMER.ITEM<2,2>

Fig. 12-6. An example of using -1 in dynamic array references.


Don't worry too much about understanding the mechanics of this process. Just remember this one simple fact about item-ids: When item-ids are sequentially assigned numbers, all of which are the same length, you get a nearly perfect "distribution" of items in a file. Item-ids that are random length, or composed of random characters, tend to distribute unevenly in a file. This means that some groups may contain items, while other groups remain empty. In this case, the file will never be able to be sized properly.

Discussing file sizing with a Pick technician is not unlike discussing religion with a television evangelist. They tend to have very strong opinions about their respective beliefs.

Several verbs allow you to analyze the distribution of items in a file. They are ISTAT, which shows the current distribution statistics, and HASH-TEST, which allows a hypothetical modulo to be tested to see how the distribution of items in the file would be if the modulo were to change. But rather than devote the next 100 pages of this book to the topic, just remember the suggestion: When you have a choice of item-ids for a file, use sequential numbers that are all the same length. Note also that the modulo for a file should always be a prime number (one that is divisible only by itself and one).


REVIEW QUIZ 10

1) What purpose does the OPEN statement serve? When is it used?

2) What purpose do attribute marks, value marks, and subvalue marks serve?

3) Using the dynamic array reference symbols, fill in the program instructions which are needed to construct an item which appears as follows:


Attribute  Contents
001        BARNEY RUBBLE
002        PO BOX 77]141 BEDROCK PLACE
003        BEDROCK
004        PA
005        19104

4) Write a routine to print the above array out in this form:

BARNEY RUBBLE
PO BOX 77
141 BEDROCK PLACE
BEDROCK, PA 19104

5) Suppose you have an array called INVOICE.ITEM that was currently "null." How does the array appear in its physical form after executing the following instructions?

INVOICE.ITEM<6,-l> = ICONV("03-04-93","D")
INVOICE. ITEM<2,3> = ICONV ( "100", "MR2" )

6) What statement is used to retrieve an item from a file?

7) What statement, or statements, are needed to retrieve an item called S1000 from a file called INVOICE-FILE?

8) What purpose does the THEN clause serve in a READ statement?

9) What purpose does the ELSE clause serve in a READ statement?

Previous chapter Next chapter Top

 

Creative Commons License
Jonathan E. Sisk's "Pick/BASIC: A Programmer's Guide" by Jonathan E. Sisk is licensed under a Creative Commons Attribution 3.0 Unported License.
Based on a work at jes.com.