home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 19 / AACD19.BIN / AACD / Programming / YAEC / examples / Watch.e < prev    next >
Encoding:
Text File  |  2001-02-23  |  838 b   |  30 lines

  1.  
  2. OPT OSVERSION=37
  3.  
  4. MODULE 'dos/notify'
  5.  
  6. PROC main()
  7.   DEF nreq:PTR TO notifyrequest,sig,task
  8.   IF (FileLength(arg)=-1) OR (arg[0]=0)     ->/* never be notified */
  9.     WriteF('file \"\s\" does not exist\n',arg)
  10.     Raise(1) ->CleanUp(10)
  11.   ENDIF
  12.   NEW nreq    ->/* memory is cleared */
  13.   sig:=AllocSignal(-1)                ->/* we want to be signalled */
  14.   IF sig=-1 THEN RETURN 10
  15.   task:=FindTask(0)
  16.   nreq.name:=arg                      ->/* fill in structure */
  17.   nreq.flags:=NRF_SEND_SIGNAL
  18.   nreq.port:=task                     ->/* union port/task */
  19.   nreq.signalnum:=sig
  20.   IF StartNotify(nreq)
  21.     WriteF('Now watching: \"\s\"\n',arg)
  22.     Wait(Shl(1,sig))
  23.     EasyRequestArgs(0,[20,0,0,'File %s modified!','Damn!'],0,[arg])
  24.     EndNotify(nreq)
  25.   ELSE
  26.     WriteF('Could not watch \"\s\".\n',arg)
  27.   ENDIF
  28.   FreeSignal(sig)
  29. ENDPROC
  30.