home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 9.11. Load an array with database structure
- and index key information.
- Author: Craig Yellick
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- function LoadSystem
- /*
- Return array containing complete information
- on all databases, fields and indexes used
- in current application.
- */
- local stru_, ntx_
- local dbf_ := {}
-
- ********************
- *** Customer.dbf ***
- ********************
- stru_ := {} ; ntx_ := {}
-
- // Fields in customer.dbf
- aadd(stru_, {"id", "C", 6, 0, "Customer ID"})
- aadd(stru_, {"name", "C", 30, 0, "Name"})
- aadd(stru_, {"address", "C", 30, 0, "Street address"})
- aadd(stru_, {"csz", "C", 30, 0, "City State ZIP"})
-
- // Indexes for customer.dbf
- aadd(ntx_, {"custID", "id", ;
- "Customers by ID"})
- aadd(ntx_, {"custName", "name +ID", ;
- "Customers by Name"})
-
- // Final array of info for customer.dbf
- aadd(dbf_, {"customer", "Master customer list", ;
- stru_, ntx_})
-
- *****************
- *** Order.dbf ***
- *****************
- stru_ := {} ; ntx_ := {}
-
- // Fields for order.dbf
- aadd(stru_, {"id", "C", 10, 0, "Order ID"})
- aadd(stru_, {"customer", "C", 6, 0, "Customer ID"})
- aadd(stru_, {"dated", "D", 8, 0, "Date of order"})
- aadd(stru_, {"sales", "C", 3, 0, "Salesperson"})
-
- // Indexes for order.dbf
- aadd(ntx_, {"ordID", "ID", ;
- "Orders by ID"})
- aadd(ntx_, {"ordCust", "Customer +dtos(Dated)", ;
- "Customer ID by date"})
-
- // Final array of info for order.dbf
- aadd(dbf_, {"order", "Customer orders", stru_, ntx_})
-
- ****************
- *** Item.dbf ***
- ****************
- /*
- Just to be different this dbf_ element is
- constructed directly without using aadd() for
- individual array components. We feel this
- method is more difficult to get right the
- first time and harder to maintain.
- */
- aadd(dbf_, {"item", "Customer order line items", ;
- { ; // Structure
- {"order", "C", 10, 0, "Order ID"}, ;
- {"invent", "C", 8, 0, "Inventory item"}, ;
- {"qty", "N", 4, 0, "Quantity"} ;
- },;
- { ; // Index
- {"itemOrd", "Order +Invent", ;
- "Order items by inventory code"} ;
- } ;
- })
-
- *** The dbf_ array now contains complete system info.
-
- return dbf_
-
- // end of file CHP0911.PRG
-