home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l217 / 2.ddi / EXAMPLES / CH19EX04.PRO < prev    next >
Encoding:
Text File  |  1990-03-26  |  937 b   |  47 lines

  1. /*
  2.    Copyright (c) 1986, 90 by Prolog Development Center
  3. */
  4. include "ch19ex03.pre"
  5.  
  6. predicates
  7. action(integer,integer)
  8. nondeterm repeat
  9. rxdir(shcom)
  10.  
  11. clauses
  12.  
  13. repeat.
  14. repeat:- repeat.
  15.  
  16. rxdir(direntry(Name,Hour,Min,Sec,Year,Month,Day,Size)):- !,
  17.     writef("%13 %:%:%\t%:%:%\t% bytes\n",
  18.                 Name,Hour,Min,Sec,Year,Month,Day,Size).
  19. rxdir(_).
  20.  
  21. action(1,H):- !,
  22.     write("Enter file spec -> "),
  23.     readln(FSpec),
  24.     msgsend(shcom,H,dir(FSpec)),
  25.     repeat,
  26.     msgrecv(shcom,_,Ans),
  27.     rxdir(Ans),
  28.     Ans = eoj(), !.
  29. action(2,H):- !,
  30.     write("Enter file name -> "),
  31.     readln(FNam),
  32.     msgsend(shcom,H,copy(FNam)),
  33.     msgrecv(shcom,_,Ans),
  34.     Ans = contents(FContents),
  35.     file_str(FNam,FContents).
  36. action(_,_).
  37.  
  38. goal
  39.     msgopen("\\pipe\\rsh",Handle,10000,100),
  40.     msgsetwait(1000),    % 10 secs
  41.     repeat,
  42.     write("Enter 0:quit; 1:dir; 2:copy file -> "),
  43.     readint(N), nl,
  44.     action(N,Handle),
  45.     N = 0,
  46.     msgclose(Handle,purge,filter).
  47.