home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l210 / 1.ddi / PROGRAMS.ARC / LISTDBA.PRO < prev    next >
Encoding:
Prolog Source  |  1988-06-21  |  3.5 KB  |  109 lines

  1. /*****************************************************************************
  2.  
  3.         LIST CONTENTS OF DATABASE
  4.  
  5.  The predicate listdba can be used to display the state of an external
  6.  database. It is called with one parameter which is the selector of an
  7.  already open database.
  8.  
  9.  It is required that all terms in the database is stored under the same
  10.  domain !.
  11.  
  12.  The name of the domain is here called mydom, it should be substituted
  13.  by the actual name.
  14.  
  15. *****************************************************************************/
  16.  
  17. DOMAINS
  18.   DB_SELECTOR    = mydba
  19.   mydom        = city(CITYNO,CITYNAME);
  20.             person(FIRSTNAME,LASTNAME,STREET,CITYNO,CODE)
  21.   CITYNO, CITYNAME, FIRSTNAME, LASTNAME, STREET, CODE = STRING
  22.  
  23.  
  24. /*****************************************************************************
  25.  
  26.             BT_KEYS
  27.  
  28. Returns through backtracking all keys and their associated database
  29. reference number for a given index and database.
  30.  
  31. *****************************************************************************/
  32.  
  33.  
  34.  
  35. PREDICATES
  36.   nondeterm bt_keys(DB_SELECTOR,BT_SELECTOR,STRING,REF)
  37.   nondeterm bt_keysloop(DB_SELECTOR,BT_SELECTOR,STRING,REF)
  38.  
  39. CLAUSES
  40.   bt_keys(DB_SELECTOR,BT_SELECTOR,KEY,REF):-
  41.     key_first(DB_SELECTOR,BT_SELECTOR,_),
  42.     bt_keysloop(DB_SELECTOR,BT_SELECTOR,KEY,REF).
  43.  
  44.   bt_keysloop(DB_SELECTOR,BT_SELECTOR,KEY,REF):-
  45.     key_current(DB_SELECTOR,BT_SELECTOR,KEY,REF).
  46.   bt_keysloop(DB_SELECTOR,BT_SELECTOR,KEY,REF):-
  47.     key_next(DB_SELECTOR,BT_SELECTOR,_),
  48.     bt_keysloop(DB_SELECTOR,BT_SELECTOR,KEY,REF).
  49.  
  50.      
  51. PREDICATES
  52.   listdba(DB_SELECTOR)
  53.  
  54. CLAUSES
  55.   listdba(DB_SELECTOR):-
  56.     write("\n***********************************************************"),
  57.     write("\n                         DATABASE LISTING"),
  58.     write("\n***********************************************************"),
  59.     db_statistics(DB_SELECTOR,NoOfTerms,MemSize,DbaSize,FreeSize),
  60.     write("\n\nTotal number of records in the database: ",NoOfTerms),
  61.     write("\nNumber of bytes used in main memory: ",MemSize),
  62.     write("\nNumber of bytes in used by the database: ",DbaSize),
  63.     write("\nNumber of bytes free on disk: ",FreeSize),
  64.     fail.
  65.  
  66.   listdba(DB_SELECTOR):-
  67.     db_chains(DB_SELECTOR,CHAIN),
  68.         write("\n\nPress key to continue"),
  69.         readchar(_),
  70.         clearwindow,    
  71.         write("\n\n\n\n******************* CHAIN LISTING *******************"),
  72.     write("\n\nName=",CHAIN),
  73.     write("\n\nCONTENT OF: ",CHAIN),
  74.     write("\n------------------------------\n"),
  75.     chain_terms(DB_SELECTOR,CHAIN,mydom,TERM,REF),
  76.     write("\n",REF,": ",TERM),
  77.     fail.
  78.   listdba(DB_SELECTOR):-
  79. /*        write("\n\nPress key to continue"),
  80.         readchar(_),
  81.         clearwindow,*/
  82.     db_btrees(DB_SELECTOR,BTREE),
  83.     bt_open(DB_SELECTOR,BTREE,BT_SELECTOR),
  84.     bt_statistics(DB_SELECTOR,BT_SELECTOR,
  85.         NoOfKeys,NoOfPages,Dept,KeyLen,Order,PageSize),
  86.         write("\n\nPress key to continue"),
  87.         readchar(_),
  88.         clearwindow,
  89.     write("\n\n\n******************** INDEX LISTING *********************"),
  90.     write("\nName=     ",BTREE),
  91.     write("\nNoOfKeys= ",NoOfKeys),
  92.     write("\nNoOfPages=",NoOfPages),
  93.     write("\nDept=     ",Dept),
  94.     write("\nOrder=    ",Order),
  95.     write("\nKeyLen=   ",KeyLen),
  96.     write("\nPageSize= ",PageSize),nl,
  97.     write("\nCONTENT OF: ",BTREE),
  98.     write("\n------------------------------"),
  99.     bt_keys(DB_SELECTOR,BT_SELECTOR,KEY,REF),
  100.     write("\n",KEY," - ",REF),
  101.     fail.
  102.   listdba(_).
  103.  
  104.  
  105. GOAL    db_open(mydba,"register.bin",in_file),
  106.         textmode(R,C),
  107.         makewindow(1,7,7,"",0,0,R,C),
  108.     listdba(mydba).
  109.