home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / library / prolo_c / exampl23.pro < prev    next >
Text File  |  1986-10-06  |  803b  |  33 lines

  1. /* Program 23 */
  2. /*
  3.   This program demonstrates the use of readln
  4.   and the extraction of compuound objects from
  5.   input lines.  If you enter the wrong type for
  6.   each item, you must try again.
  7. */  
  8.   
  9. domains
  10.     person      = p(name,age,telno,job)
  11.     age         = integer
  12.     telno ,name,job = string
  13.  
  14. predicates
  15.     readperson(person)
  16.     run
  17.  
  18. goal
  19.     run.
  20.  
  21. clauses
  22.     readperson(p(Name,Age,Telno,Job)):-
  23.         write("Which name ? "),readln(Name),
  24.         write("Job ?"),readln(Job),
  25.         write("Age ?"),readint(Age),
  26.         write("Telephone no ?"),readln(Telno).
  27.     run:-
  28.         readperson(P),nl,write(P),nl,nl,
  29.         write("Is this compound object OK (y/n)"),
  30.         readchar(Ch),Ch='y'.
  31.     run:-
  32.         nl,nl,write("Alright, try again"),nl,nl,run.
  33.