🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #766

Time and Date in Quintus P.

#766
From: Joern Baier
Date: Thu, 03 Sep 1992 20:10
54 lines
2192 bytes
Hi!

For an application I need the time and date in Quintus Prolog. I wrote a
small predicate date/1 but I'm not content with it, because I have to
create an extra file. How can I get a random number in PROLOG to create
unique file names?
The main problem is that 'unix(system(date))' sends its output directly
to the user, regardless of the current output.
 
I enclose the protocol of a session below.

Thanx in advance,
			Joern
-------------------------------Cut here!------------------------------
gandalf:~/prolog/dp 103> prolog

Quintus Prolog Release 2.5.1 (DECstation 3100, Ultrix 3.1)
Copyright (C) 1990, Quintus Computer Systems, Inc.  All rights reserved.
1310 Villa Street, Mountain View, California  (415) 965-7700

| ?-  tell(test_2),current_output(O),unix(system(date)),told.
Thu Sep  3 22:01:06 MET DST 1992

O = '$stream'(35,3) 

| ?- [system].
[consulting /home/forwiss/baier/prolog/dp/system.pl...]
...
 [consulting /private/projects/quintus/generic/qplib2.5.1/library/readin.pl...]
 [readin.pl consulted in module read_in 0.200 sec 2,844 bytes]
[system.pl consulted in module system 2.000 sec 40,736 bytes]

yes
| ?- listing(date).

system:(date(A) :-
        tell('________Datum_Uhrzeit'),
        told,
        unix(system('date > ________Datum_Uhrzeit')),
        open('________Datum_Uhrzeit',read,B),
        set_input(B),
        read_in(A),
        close(B).

yes
| ?- date(Date).

Date = [thu,sep,3,21,:,56,:,52,met,dst,1992,''] 
----------------------------Cut again!------------------------------------
-- 
Joern Baier     (baier@forwiss.uni-passau.de) 
Jesuitengasse 9 	   __o
D-W8390 Passau 		 _ \<,_
Tel +49/851/35239 	(_)/ (_)
Technical Details
Message-ID: <1992Sep3.201023.6191@tom.rz.uni-passau.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!math.fu-berlin.de!informatik.tu-muenchen.de!rz.uni-passau.de!forwiss.uni-passau.de!baier

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.prolog
Path: arc1-ca.pugleaf.net!sparky!uunet!math.fu-berlin.de!informatik.tu-muenchen.de!rz.uni-passau.de!forwiss.uni-passau.de!baier
From: baier@forwiss.uni-passau.de (Joern Baier)
Subject: Time and Date in Quintus P.
Message-ID: <1992Sep3.201023.6191@tom.rz.uni-passau.de>
Sender: news@tom.rz.uni-passau.de (News-Operator)
Nntp-Posting-Host: gandalf.forwiss.uni-passau.de
Organization: University of Passau, Germany
Date: Thu, 3 Sep 1992 20:10:23 GMT
Lines: 54