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

  1. /*
  2.    Listing 9.13. Create index files based on contents of array.
  3.    Author: Craig Yellick
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11. #include "dbfsytem.ch"
  12.  
  13. function SysIndex(sys_, which)
  14. /*
  15.    Given a system structure array and an optional
  16.    database filename, create associated index(es).
  17. */
  18.  
  19. local n
  20.   if which <> nil
  21.     n := ascan(sys_, ;
  22.          { |d_| upper(d_[SYS_DBFNAME]) == upper(which)})
  23.     if n > 0
  24.       SysIndex1(sys_[n, SYS_DBFNAME], sys_[n, SYS_NTX])
  25.     else
  26.       //  Error handler?
  27.     endif
  28.  
  29.   else
  30.     for n := 1 to len(sys_)
  31.       SysIndex1(sys_[n, SYS_DBFNAME], sys_[n, SYS_NTX])
  32.     next n
  33.   endif
  34. return nil
  35.  
  36. static function SysIndex1(dbfname, ntx_)
  37. local i
  38. local key
  39.   for i := 1 to len(ntx_)
  40.     use (dbfname) new
  41.     key := ntx_[i, NTX_KEY]
  42.     index on &key. to (ntx_[i, NTX_NAME])
  43.     use
  44.   next i
  45. return nil
  46.  
  47. // end of file CHP0913.PRG
  48.