home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / X_PROLOG.LZH / X_PROLOG / SYSTEM < prev    next >
Text File  |  1990-08-13  |  1KB  |  56 lines

  1. % more stuff for a suitable user interface
  2. % please note, that this module relies heavily on the system facility
  3. % system must be consulted AFTER listing
  4.  
  5. :- op(1, fx, edit).
  6. :- op(1, fx, time).
  7.  
  8. shell <-
  9.     ' call your favourite shell from prolog '.
  10. shell :- my_favourite_shell_is(Shell), system(Shell).
  11.  
  12. my_favourite_shell_is(msh).
  13.  
  14. (edit name/arity) <-
  15.     ' edit the named procedure '.
  16. (edit Name/Arity) :-
  17.     tell(atempfile),
  18.     ( functor(Head, Name, Arity),
  19.       clause(Head, _),
  20.       !,                        % there is a clause
  21.       listing(Head)                    % write it to the file
  22.       ;
  23.       writeq('"There is now clause '),
  24.       writeq(Name/Arity),
  25.       writeq(' in the database"')
  26.     ),
  27.     told,
  28.     (edit atempfile),
  29.     rename(atempfile, []).                % delete it
  30. (edit file) <-
  31.     ' edit the named module '.
  32. (edit File) :-
  33.     name(File, Filename),
  34.     my_favourite_editor_is(Editor),
  35.     append(Editor, Filename, Commandline),
  36.     name(Command, Commandline),
  37.     system(Command),
  38.     reconsult(File).
  39.  
  40. my_favourite_editor_is("emacs ").    % watch out for the blank
  41.  
  42. (time goal) <-
  43.     ' compute the time the goal needs for it''s proof '.
  44. (time Goal) :-
  45.     OldTime is cputime,
  46.     call(Goal),
  47.     !,
  48.     Difference is cputime - OldTime,
  49.     write('Time : '),
  50.     write(Difference),
  51.     write(' msec.'),
  52.     nl.
  53.  
  54. :- hide([shell, (edit _), (edit _/_), my_favourite_editor_is(_),
  55.     my_favourite_shell_is(_), (time _)]).
  56.