home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Borland Plateform / Turbo Prolog 2 / EXAMPL59.PRO < prev    next >
Encoding:
Text File  |  1986-04-25  |  1.1 KB  |  32 lines

  1.                     /* Program 59 */
  2.  
  3. include "exampl58.pro"  /*excluding the goal*/
  4. domains
  5.     row,col,length=integer
  6.     field=f(row,col,length)
  7.     position=pos(row,col)
  8. predicates
  9.     scr(field,position,key)
  10. goal
  11.     Row=10,Col=10,Length=30,cursor(Row,Col),
  12.     makewindow(1,23,1,"Example Editor",0,0,25,80),
  13.     write("Edit the text. Use the arrow keys to move"),
  14.     field_attr(Row,Col,Length,112),
  15.     scr(f(Row,Col,Length),pos(Row,Col),home),nl,nl,
  16.     field_str(Row,Col,Length,Contents),
  17.     write("Edited contents: ",Contents).
  18. clauses
  19.     scr(_,_,esc):-!, fail.
  20.     scr(_,_,fkey(10)):-!.
  21.     scr(f(Row,Col,L),pos(R,C),char(Ch)):-
  22.         scr_char(R,C,Ch),C1=C+1,C1<C+L,cursor(R,C1),
  23.         readkey(Key), scr(f(Row,Col,L),pos(R,C1),Key).
  24.     scr(f(Row,Col,L),pos(R,C),right):-
  25.         C1=C+1,!,C1<C+L,cursor(R,C1),readkey(Key),
  26.         scr(f(Row,Col,L),pos(R,C1),Key).
  27.     scr(f(Row,Col,L),pos(R,C),left):-
  28.         C1=C-1,C1>=Col,cursor(R,C1),
  29.         readkey(Key),scr(f(Row,Col,L),pos(R,C1),Key).
  30.     scr(Field,Pos,_):-
  31.         beep,readkey(Key),scr(Field,Pos,Key).
  32.