home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 9.13. Create index files based on contents of array.
- 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
- */
-
- #include "dbfsytem.ch"
-
- function SysIndex(sys_, which)
- /*
- Given a system structure array and an optional
- database filename, create associated index(es).
- */
-
- local n
- if which <> nil
- n := ascan(sys_, ;
- { |d_| upper(d_[SYS_DBFNAME]) == upper(which)})
- if n > 0
- SysIndex1(sys_[n, SYS_DBFNAME], sys_[n, SYS_NTX])
- else
- // Error handler?
- endif
-
- else
- for n := 1 to len(sys_)
- SysIndex1(sys_[n, SYS_DBFNAME], sys_[n, SYS_NTX])
- next n
- endif
- return nil
-
- static function SysIndex1(dbfname, ntx_)
- local i
- local key
- for i := 1 to len(ntx_)
- use (dbfname) new
- key := ntx_[i, NTX_KEY]
- index on &key. to (ntx_[i, NTX_NAME])
- use
- next i
- return nil
-
- // end of file CHP0913.PRG
-