home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / prolog / 1645 < prev    next >
Encoding:
Text File  |  1992-09-03  |  2.1 KB  |  66 lines

  1. Newsgroups: comp.lang.prolog
  2. Path: sparky!uunet!math.fu-berlin.de!informatik.tu-muenchen.de!rz.uni-passau.de!forwiss.uni-passau.de!baier
  3. From: baier@forwiss.uni-passau.de (Joern Baier)
  4. Subject: Time and Date in Quintus P.
  5. Message-ID: <1992Sep3.201023.6191@tom.rz.uni-passau.de>
  6. Sender: news@tom.rz.uni-passau.de (News-Operator)
  7. Nntp-Posting-Host: gandalf.forwiss.uni-passau.de
  8. Organization: University of Passau, Germany
  9. Date: Thu, 3 Sep 1992 20:10:23 GMT
  10. Lines: 54
  11.  
  12. Hi!
  13.  
  14. For an application I need the time and date in Quintus Prolog. I wrote a
  15. small predicate date/1 but I'm not content with it, because I have to
  16. create an extra file. How can I get a random number in PROLOG to create
  17. unique file names?
  18. The main problem is that 'unix(system(date))' sends its output directly
  19. to the user, regardless of the current output.
  20.  
  21. I enclose the protocol of a session below.
  22.  
  23. Thanx in advance,
  24.             Joern
  25. -------------------------------Cut here!------------------------------
  26. gandalf:~/prolog/dp 103> prolog
  27.  
  28. Quintus Prolog Release 2.5.1 (DECstation 3100, Ultrix 3.1)
  29. Copyright (C) 1990, Quintus Computer Systems, Inc.  All rights reserved.
  30. 1310 Villa Street, Mountain View, California  (415) 965-7700
  31.  
  32. | ?-  tell(test_2),current_output(O),unix(system(date)),told.
  33. Thu Sep  3 22:01:06 MET DST 1992
  34.  
  35. O = '$stream'(35,3) 
  36.  
  37. | ?- [system].
  38. [consulting /home/forwiss/baier/prolog/dp/system.pl...]
  39. ...
  40.  [consulting /private/projects/quintus/generic/qplib2.5.1/library/readin.pl...]
  41.  [readin.pl consulted in module read_in 0.200 sec 2,844 bytes]
  42. [system.pl consulted in module system 2.000 sec 40,736 bytes]
  43.  
  44. yes
  45. | ?- listing(date).
  46.  
  47. system:(date(A) :-
  48.         tell('________Datum_Uhrzeit'),
  49.         told,
  50.         unix(system('date > ________Datum_Uhrzeit')),
  51.         open('________Datum_Uhrzeit',read,B),
  52.         set_input(B),
  53.         read_in(A),
  54.         close(B).
  55.  
  56. yes
  57. | ?- date(Date).
  58.  
  59. Date = [thu,sep,3,21,:,56,:,52,met,dst,1992,''] 
  60. ----------------------------Cut again!------------------------------------
  61. -- 
  62. Joern Baier     (baier@forwiss.uni-passau.de) 
  63. Jesuitengasse 9        __o
  64. D-W8390 Passau          _ \<,_
  65. Tel +49/851/35239     (_)/ (_)
  66.