1996-09-27 06:29:02 -04:00
|
|
|
|
;;;;
|
|
|
|
|
;;;; f i l e e v e n t . s t k -- Implement the Tk fileevent commeand
|
|
|
|
|
;;;; in term of when-port-{read|writ}able
|
|
|
|
|
;;;; For backward compatibility ...
|
|
|
|
|
;;;;
|
|
|
|
|
;;;;
|
1999-09-05 07:16:41 -04:00
|
|
|
|
;;;; Copyright <20> 1993-1999 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
|
1996-09-27 06:29:02 -04:00
|
|
|
|
;;;;
|
1999-09-05 07:16:41 -04:00
|
|
|
|
;;;; Permission to use, copy, modify, distribute,and license this
|
|
|
|
|
;;;; software and its documentation for any purpose is hereby granted,
|
|
|
|
|
;;;; provided that existing copyright notices are retained in all
|
|
|
|
|
;;;; copies and that this notice is included verbatim in any
|
|
|
|
|
;;;; distributions. No written agreement, license, or royalty fee is
|
|
|
|
|
;;;; required for any of the authorized uses.
|
|
|
|
|
;;;; This software is provided ``AS IS'' without express or implied
|
|
|
|
|
;;;; warranty.
|
1996-09-27 06:29:02 -04:00
|
|
|
|
;;;;
|
|
|
|
|
;;;; Author: Erick Gallesio [eg@unice.fr]
|
|
|
|
|
;;;; Creation date: 16-Jun-1996 22:37
|
1999-09-05 07:16:41 -04:00
|
|
|
|
;;;; Last file update: 3-Sep-1999 19:51 (eg)
|
1996-09-27 06:29:02 -04:00
|
|
|
|
|
1998-04-10 06:59:06 -04:00
|
|
|
|
(select-module Tk)
|
1996-09-27 06:29:02 -04:00
|
|
|
|
|
|
|
|
|
(define (fileevent file mode . script)
|
|
|
|
|
(define (err)
|
|
|
|
|
(error "fileeevent: bad mode specification ~S.\n(Note: fileevent is obsolete; use when-port-readable or when-port-writable)" mode))
|
|
|
|
|
|
|
|
|
|
(let ((smode (& mode))
|
|
|
|
|
(fct #f))
|
|
|
|
|
(cond
|
|
|
|
|
((equal? smode "readable") (set! fct when-port-readable))
|
|
|
|
|
((equal? smode "writable") (set! fct when-port-writable))
|
|
|
|
|
(ELSE (err)))
|
|
|
|
|
(if (null? script)
|
|
|
|
|
(fct file)
|
|
|
|
|
(let ((s (car script)))
|
|
|
|
|
(cond
|
|
|
|
|
((procedure? s) (fct file s))
|
|
|
|
|
((string? s) (if (string=? s "") (fct file #f) (err)))
|
|
|
|
|
(ELSE (err)))))))
|
|
|
|
|
|
1998-09-30 07:11:02 -04:00
|
|
|
|
(define Tk:fileevent fileevent)
|
1996-09-27 06:29:02 -04:00
|
|
|
|
|
1998-04-10 06:59:06 -04:00
|
|
|
|
|