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

Guide to TCL scripting for Eggdrop 1.6


[ Previous ] [ Index ] [ Next ]


11.5 The end of the file

In some cases you might not know how large a file and thus don't know up until where to read from the file.
With the eof command you can find out if the end of the file has been reached.
The syntax of an eof command is eof <channel>.

The <channel> is the channel of the file you cought with the open command.

The eof command returns a 1 if the last command that accessed the channel gave an "end of file" report and a 0 if it didn't.

A way to use the eof command is in a while loop for instance. Here's an example:

set found 0
set fs [open $file r]
while {![eof $fs]} {
  gets $fs line
  if {$line == $nick} { set found 1 }
}
close $fs
if {$found} {
  putdcc $idx "$nick was found!"
} else {
  putdcc $idx "$nick was not found."
}

This would check every line of $file and tell whether or not one of those lines was equal to $nick.


[ Previous ] [ Index ] [ Next ]


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