SUNiNET - Your Eggdrop & TCL resources site
[ Home Eggdrop TCL Links About ]

Guide to TCL scripting for Eggdrop 1.6


[ Previous ] [ Index ] [ Next ]


11.1 Opening files

Before you can use a file you will have to open it. This can be done with the open command.
The syntax of an open command is open <filename> [access].

The <filename> is the name of the file you want to open.

The [access] is what you want to do with the file.
Here is a list of different access types according to the man pages of TCL 8.0.4:

  r   Open the file for reading only; the file must already exist.
      This is the default value if access is not specified.

  r+  Open the file for both reading and writing; the file must already exist.

  w   Open the file for writing only. Truncate it if it exists.
      If it doesn't exist, create a new file.

  w+  Open the file for reading and writing. Truncate it if it exists.
      If it doesn't exist, create a new file.

  a   Open the file for writing only. The file must already exist,
      and the file is positioned so that new data is appended to the file.

  a+  Open the file for reading and writing. If the file doesn't exist,
      create a new empty file. Set the initial access position to the end of the file.

The open command command returns a so called channel.
You will need this channel if you want to do something with the file so you have to "catch" this channel.
This can be done by putting the channel in a string. An example would be set fs [open $file r], which would save the channel of $file to $fs.


[ Previous ] [ Index ] [ Next ]


Design & Graphics by Shawn Borton
Copyright © 2000-2005 Marijn van Zon