chan event

Gives or sets the script that the event loop runs when a channel can be read or written.

chan event CHAN EVENT ?SCRIPT?

Description

With SCRIPT it sets the script for EVENT, readable or writable, of CHAN, and an empty SCRIPT removes it. With no SCRIPT it gives the script, or an empty string. The script runs in the event loop.

Arguments

ArgumentTypeDefaultDescription
CHANchannelrequiredThe channel.
EVENTreadable or writablerequiredThe event.

Values: readable, writable.

SCRIPTscriptnoneThe script for the event.

Returns

The script, or an empty string.

Examples

% set f [open a.txt w]; chan close $f
> set f [open a.txt]
> chan event $f readable {set x 1}
> set r [chan event $f readable]
> chan close $f
> set r
set x 1

Errors

% chan event stdin bogus
bad event name "bogus": must be readable or writable
-errorcode TCL LOOKUP INDEX {event name}

Facts

Capability
channels. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also