home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / library / prolo_c / exampl43.pro < prev    next >
Text File  |  1986-10-06  |  859b  |  34 lines

  1. /* Program 43 */
  2. /*
  3.   Read 'The Turbo Prolog File System' in chapter
  4.   9 . This example is on page 102.
  5. */
  6.  
  7. domains
  8.     file = myfile
  9.  
  10. predicates
  11.     start
  12.     readin(char)
  13.  
  14. goal
  15.     start.
  16.  
  17. clauses
  18.     start:-
  19.         write("This program reads input\nfrom the keyboard and\nwrites it to TRYFILE.ONE.\n"),
  20.         write("Press # when done entering:\n"),
  21.         openwrite(myfile,"tryfile.one"),
  22.         readchar(X),
  23.         readin(X),
  24.         closefile(myfile),
  25.         writedevice(screen),
  26.         write("Your input has been transferred to a file").
  27.     readin( '#' ):-!.
  28.     readin('\13'):-!,writedevice(myfile),
  29.         write("\13\10"),writedevice(screen),
  30.         write("\13\10"),readchar(X),readin(X).
  31.     readin(  X  ):- writedevice(myfile),
  32.         write(X),writedevice(screen),
  33.         write(X),readchar(Y),readin(Y).
  34.