
1 Introduction
10 DIM Buf$[170],B$[5],Order_no$[10],Names$[30]
20 INTEGER S(9) ! Ten-element status array.
30 B$="SAD"
40 DBOPEN (B$,"SECRET",3,S(*)) ! Open the database.
50 DBASE IS B$
60 IN DATA SET "CUSTOMERS" USE Order_no$,Name$
70 ! Now set up a workfile with CUSTOMER as the thread.
.
.
.
110 ! Sort the orders by order number.
.
.
140 PRINT " ORDER NUMBER";TAB(30);"CUSTOMER NAME";LIN(2)
150 FOR I=1 TO Entry_count
160 ! Read the record pointer into Rec_no.
.
180 DBGET (B$,"CUSTOMER",4,S(*),"@",Buf$,Rec_no)
190 PRINT Order_no$;TAB(30);Name$
200 NEXT I
210 DBCLOSE (B$," ",1,S(*))
.
230 END
RUN
ORDER NUMBER CUSTOMER NAME
10 ABC Company
100 Colorado Feed and Grain
12.6 Bruce's Bar & Grill
17.2 Timmy's Pet Store
20 ABC Company
999 Internal Revenue Service
In many respects, the workfile is just like a regular data file. It must be CREATEd and ASSIGNed just like a DATA file. Only its use in the program distinguishes it as a workfile. After the program defines a file as a workfile, it remains that way until either it is de-ASSIGNed or the program stops. Since the workfile is so similar to a normal data file, most of the standard file operations work on it. Record pointers are read from the workfile with the READ # statement, and pointers may be added to it using PRINT #. The next figure shows how the contents of the workfile are related to the base entries used in the previous example.

Figure 2 Data Base/Workfile Relationship