#!/usr/local/bin/rexx

'/bin/ls data/ >FIFO'

DO i=1 TO QUEUED()
   PARSE PULL user.i 
END 
user.0=i-1

last=-1
DO i=1 TO user.0
   user=user.i
   IF LEFT(user, 3)='ppp' THEN ITERATE
   '/bin/cat data/'user' >LIFO'
   ukupno=0
   DO k=1 TO QUEUED()
      PARSE PULL flag time
      IF last=0 & flag=1 THEN DO
         ukupno=ukupno+(ltime-time)
         last=-1
         END
      last=flag; ltime=time
   END
   CALL Report User Ukupno
END

EXIT

Report: PArse ARG user time
sati=TRUNC(time/60)
minuta=time-(sati*60)
SAY LEFT(user, 8)' 'RIGHT(sati, 4)':'RIGHT('0'minuta, 2)
RETURN

