FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log inLog in 


Some lesson: which file is more updated than the other?

Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog Tips & Samples
View previous topic :: View next topic  
Author Message
Peter Muraya



Nairobi, Kenya
Joined: 05 Dec 2012
Posts: 148

PostPosted: 17 Jul 2015 5:41    Post subject: Some lesson: which file is more updated than the other? Reply with quote

I needed to implement a predicate that tells me if one file is more updated than another. Here is how I went about it and the lesson I learnt.

/*
This predicated succeeds if the first file is more updated than the second one*/

predicates
     is_more_updated:(string Filename1, string Filename2) determ.
clauses
     is_more_updated(Filename1, Filename2):-
          /*
          Get the GMT times when the files were last changed*/

          file::getFileProperties(Filename1,_,_,_,_,Gmt1),
          file::getFileProperties(Filename2,_,_,_,_,Gmt2),
          /*
          Now I need to find out which date/time is more recent and I tried the following:-
         
          Gmt1>Gmt2,!, %This compiled but gave me wrong results; then I tried:-
         
          compare(Gmt1, Gmt2) = ::greater,!, %This too compiled but gave me wrong results. Finally I tried (which worked):-*/

          Time1=time::newFromGMT(Gmt1),
          Time2=time::newFromGMT(Gmt2),
          Time1:compare(Time2)=::greater.


_________________
Mutall Data Management Technical Support
Back to top
View user's profile Send private message
Thomas Linder Puls



Copenhagen, Denmark
Joined: 28 Feb 2000
Posts: 3077

PostPosted: 17 Jul 2015 13:36    Post subject: Reply with quote

It is very strange that you have gotten wrong results when comparing the gmtTimeValue's directly, that should work. Notice that compare on time (which is actually gtmTime::compare) does actually just compare the gmtTimeValue's:

clauses
    compare(AnotherTime) = compare(gmtTimeValue, AnotherTime:gmtTimeValue).


_________________
Regards Thomas Linder Puls
Prolog Development Center
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    discuss.visual-prolog.com Forum Index -> Visual Prolog Tips & Samples All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum