home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l217 / 2.ddi / EXAMPLES / CH15EX06.PRO < prev    next >
Encoding:
Text File  |  1990-03-26  |  948 b   |  40 lines

  1. /*
  2.    Copyright (c) 1986, 90 by Prolog Development Center
  3. */
  4.  
  5. constants
  6. % register.bin may be in the programs directory "..\\programs\\register.bin"   
  7.   filename = "register.bin"
  8.    
  9. domains
  10.    Db_selector = myDba
  11.    chainterm  = chain(string, mydom)
  12.    file = outfile
  13.    mydom = city(zipcode, cityname);
  14.    person(firstname, lastname, street, zipcode, code)
  15.    zipcode, cityname, firstname, lastname = string
  16.    street, code = string
  17.  
  18. predicates
  19.    wr(chainterm)
  20.    dumpDba(string, string)
  21.  
  22. clauses
  23.    wr(X) :- write(X), nl.
  24.  
  25.    dumpDba(Db_selector, OutFile) :-
  26.       db_open(myDba, Db_selector, in_file),
  27.       openwrite(outfile, OutFile),
  28.       writedevice(outfile), 
  29.       db_chains(myDba, Chain),
  30.       chain_terms(myDba, Chain, mydom, Term, _),
  31.       wr(chain(Chain, Term)),
  32.       fail.
  33.  
  34.    dumpDba(_, _) :-
  35.       closefile(outfile),
  36.       db_close(myDba).
  37.  
  38. goal
  39.    dumpDba(filename, "register.txt").
  40.