!NEWSCHECK
%include "inc:util.imp"
%include "inc:fs.imp"
%include "inc:fsutil.imp"
%begin
%string(31)person=cliparam
%string(31)topic
%string(31)ref
%string(31)stamp
%record(finfof)frec
%integer sym

%onevent 3,9 %start
  %stop
%finish

%routine mangle(%string(31)%name d)
! assume D contains dd/mm/yyhh.mm
! swap about the yy and dd so that time stamp
! comparisons can be made using string comparison
%bytename d1,d2,y1,y2
%byte t1,t2
  d1 == charno(d,1)
  d2 == charno(d,2)
  y1 == charno(d,7)
  y2 == charno(d,8)
  t1 = d1; t2 = d2
  d1 = y1; d2 = y2
  y1 = t1; y2 = t2
%end

%predicate recent
! true iff the time stamp in STAMP is more recent than REF
  %trueif stamp>=ref
  %false
%end

person = currentuser %if person=""
unpackfinfo(ninfo(person.":news.seen"),frec)
ref = frec_date.frec_time
mangle(ref)
openinput(1,person.":news.seen")
selectinput(1)
%cycle
  read(topic); readsymbol(sym) %until sym=nl
  length(topic) = length(topic)-1
  unpackfinfo(ninfo("news:".topic),frec)
  stamp = frec_date.frec_time
  mangle(stamp)
  %if recent %start
    printstring("There is news in topic ".topic); newline
  %finish
%repeat

%endofprogram
