home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP09.EXE / CHP0911.PRG < prev    next >
Encoding:
Text File  |  1991-06-01  |  2.5 KB  |  89 lines

  1. /*
  2.    Listing 9.11. Load an array with database structure
  3.                  and index key information.
  4.    Author: Craig Yellick
  5.    Excerpted from "Clipper 5: A Developer's Guide"
  6.    Copyright (c) 1991 M&T Books
  7.                       501 Galveston Drive
  8.                       Redwood City, CA 94063-4728
  9.                       (415) 366-3600
  10. */
  11.  
  12. function LoadSystem
  13. /*
  14.     Return array containing complete information
  15.     on all databases, fields and indexes used
  16.     in current application.
  17. */
  18. local stru_, ntx_
  19. local dbf_ := {}
  20.  
  21.   ********************
  22.   *** Customer.dbf ***
  23.   ********************
  24.   stru_ := {} ; ntx_ := {}
  25.  
  26.   //  Fields in customer.dbf
  27.   aadd(stru_, {"id",      "C",  6, 0, "Customer ID"})
  28.   aadd(stru_, {"name",    "C", 30, 0, "Name"})
  29.   aadd(stru_, {"address", "C", 30, 0, "Street address"})
  30.   aadd(stru_, {"csz",     "C", 30, 0, "City State ZIP"})
  31.  
  32.   //  Indexes for customer.dbf
  33.   aadd(ntx_, {"custID",   "id", ;
  34.                 "Customers by ID"})
  35.   aadd(ntx_, {"custName", "name +ID", ;
  36.                 "Customers by Name"})
  37.  
  38.   //  Final array of info for customer.dbf
  39.   aadd(dbf_, {"customer", "Master customer list", ;
  40.               stru_, ntx_})
  41.  
  42.   *****************
  43.   *** Order.dbf ***
  44.   *****************
  45.   stru_ := {} ; ntx_ := {}
  46.  
  47.   //  Fields for order.dbf
  48.   aadd(stru_, {"id",       "C", 10, 0, "Order ID"})
  49.   aadd(stru_, {"customer", "C",  6, 0, "Customer ID"})
  50.   aadd(stru_, {"dated",    "D",  8, 0, "Date of order"})
  51.   aadd(stru_, {"sales",    "C",  3, 0, "Salesperson"})
  52.  
  53.   //  Indexes for order.dbf
  54.   aadd(ntx_, {"ordID",  "ID", ;
  55.                 "Orders by ID"})
  56.   aadd(ntx_, {"ordCust", "Customer +dtos(Dated)", ;
  57.                 "Customer ID by date"})
  58.  
  59.   //  Final array of info for order.dbf
  60.   aadd(dbf_, {"order", "Customer orders", stru_, ntx_})
  61.  
  62.   ****************
  63.   *** Item.dbf ***
  64.   ****************
  65.   /*
  66.      Just to be different this dbf_ element is
  67.      constructed directly without using aadd() for
  68.      individual array components. We feel this
  69.      method is more difficult to get right the
  70.      first time and harder to maintain.
  71.   */
  72.   aadd(dbf_, {"item", "Customer order line items", ;
  73.     { ;  //  Structure
  74.       {"order",  "C", 10, 0, "Order ID"}, ;
  75.       {"invent", "C",  8, 0, "Inventory item"}, ;
  76.       {"qty",    "N",  4, 0, "Quantity"} ;
  77.     },;
  78.     { ;  //  Index
  79.       {"itemOrd", "Order +Invent", ;
  80.        "Order items by inventory code"} ;
  81.     } ;
  82.   })
  83.  
  84.   *** The dbf_ array now contains complete system info.
  85.  
  86. return dbf_
  87.  
  88. // end of file CHP0911.PRG
  89.