As mentioned previously, you may use the fconfigure
command to set or get the configuration options for an open channel. The syntax is as follows:
fconfigure channel name value name value…
If invoked with no option names or values, the fconfigure
command will return the configuration options for the channel specified. Optionally, a configuration name may be passed to get the configurations for the option specified. If name and value pairs are passed the file will be configured based on the name/value pairs supplied.
The syntax of acceptable options and their descriptions are as follows:
Option |
Description |
---|---|
|
This determines if the I/O operations can result in indefinite blocking. Acceptable values must be provided in the standard Tcl Boolean format. |
|
If set to |
|
The value of |
|
This will set the encoding for the channel to allow data to be converted to and from Unicode for use by Tcl. Default encoding is system and locale specific. |
|
Specifies the end of file character. |
|
Acceptable values for mode are as follows:
|
Enter the following command:
% set fp [open text.txt r]
file3f40
$fconfigure $fp
-blocking 1 -buffering full -buffersize 4096 -encoding cp1252 -eofchar ->
-translation auto
In the preceding example, we have returned the current options for the file specified by $fp
. To obtain a single value, we would perform the following:
% fconfigure $fp -buffersize
4096
18.217.254.118