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

  1. /* Program 58 */
  2. /*
  3.   Goals are commented out since this program is used
  4.   as an "include" file to Program 59.
  5. */
  6.  
  7. domains
  8.     key = cr;esc;break;tab;btab;del;bdel;ins;end;home;
  9.         fkey(integer);up;down;left;right;char(CHAR);other
  10.  
  11. predicates
  12.     readkey(key)
  13.     key_code(key,char,integer)
  14.     key_code2(key,integer)
  15.  
  16. /*
  17. goal
  18.     write("Keyboard test. Press a key!"),
  19.     readkey(Key),
  20.     write("The ",Key,"-key was pressed").
  21. */
  22.  
  23. clauses
  24.     readkey(Key):-
  25.         readchar(T),char_int(T,Val),key_code(Key,T,Val).
  26.  
  27.     key_code(Key,_,0):-
  28.         readchar(T),char_int(T,Val),key_code2(Key,Val),!.
  29.     key_code(break,_,3):-!.      key_code(bdel,_,8):-!.
  30.     key_code(tab,_,10):-!.       key_code(cr,_,13):-!.
  31.     key_code(esc,_,27):-!.       key_code(char(T),T,_).
  32.     key_code2(btab,15):-!.       key_code2(home,71):-!.
  33.     key_code2(up,72):-!.         key_code2(left,75):-!.
  34.     key_code2(right,77):-!.      key_code2(end,79):-!.
  35.     key_code2(down,80):-!.       key_code2(ins,82):-!.
  36.     key_code2(del,83):-!.
  37.     key_code2(fkey(N),V):- V>58, V<70, N=V-58, !.
  38.     key_code2(other,_).
  39.