home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l210 / 1.ddi / EXAMPLES.ARC / CH18EX10.PRO < prev    next >
Encoding:
Prolog Source  |  1988-06-21  |  874 b   |  32 lines

  1. /*
  2.    Turbo Prolog 2.0 Chapter 18, Example Program 10
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.    
  8. predicates
  9.    wait(char)
  10.    equal(char, char)
  11.    test(string)
  12.  
  13. goal
  14.    makewindow(3, 7, 0, "", 0, 0, 25, 80),
  15.    makewindow(2, 7, 7, "Key to press now", 2, 5, 6, 70),
  16.    makewindow(1, 7, 7, "Accepted letters", 8, 10, 10, 60),
  17.    Word = "Peter Piper picked a peck of pickled peppers",
  18.    write("Please type :\n\t", Word,"\n\t"),
  19.    time(0, 0, 0, 0), test(Word),
  20.    time(_, _, S, H),
  21.    shiftwindow(1),
  22.    write("\nYou took ", S, " seconds and ", H, " hundredths").
  23.  
  24. clauses
  25.    wait(X) :- inkey(Y), equal(X, Y).
  26.    wait(X) :- shiftwindow(2), write(X), wait(X).
  27.    test(W) :- frontchar(W, Ch, R), wait(Ch),
  28.               shiftwindow(2), write(Ch), test(R).
  29.    test("").
  30.    equal(X, X) :- !.
  31.    equal(_, _) :- beep, fail.
  32.