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

  1. /*
  2.    Turbo Prolog 2.0 Chapter 14, Example Program 2
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.    
  8. predicates
  9.    start
  10.    run(integer)
  11.    do_sums
  12.    set_up_windows
  13.    clear_windows
  14.  
  15. clauses
  16.    start :- set_up_windows, do_sums.
  17.  
  18.    set_up_windows :-
  19.       makewindow(1, 7, 7, "", 0, 0, 25, 80),
  20.       makewindow(1, 7, 7, "Left operand", 2, 5, 5, 25),
  21.       makewindow(2, 7, 7, "", 2, 35, 5, 10),
  22.       nl, write(" PLUS"),
  23.       makewindow(2, 7, 7, "Right operand", 2, 50, 5, 25),
  24.       makewindow(3, 7, 7, "Gives", 10, 27, 5, 25),
  25.       makewindow(4, 7, 7, "", 17, 22, 5, 35).
  26.  
  27.    do_sums :- run(_), clear_windows, do_sums.
  28.  
  29.    run(Z) :-
  30.       shiftwindow(1),
  31.       cursor(2, 1), readint(X),
  32.       shiftwindow(2),
  33.       cursor(2, 10), readint(Y),
  34.       shiftwindow(3), Z=X+Y, cursor(2, 10), write(Z),
  35.       shiftwindow(4),
  36.       write("  Please press the space bar"),
  37.       readchar(_).
  38.  
  39.    clear_windows :-
  40.       shiftwindow(1), clearwindow,
  41.       shiftwindow(2), clearwindow,
  42.       shiftwindow(3), clearwindow,
  43.       shiftwindow(4), clearwindow.
  44.