home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / library / prolo_c / exampl59.pro < prev    next >
Text File  |  1986-10-06  |  1KB  |  38 lines

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