Extreme beginner experiencing problems with reading files 
Author Message
 Extreme beginner experiencing problems with reading files

I am an extreme beginner to all of Tcl/Tk and stumbled upon this so maybe
some of the experts here can help get a newb started.

I'm writing a simple Tcl script that parses file, checks for a specific tag
in the file and then outputs that tag.
My code goes something like

set FileList [GrabFiles /home]
foreach File $FileList {
    set InFile [open $File r]
        while {[gets $InFile line] != -1} {
            if {[string first "<BODY>" $line] != -1} {
                rest of code

My problem is when it gets to the

while {[gets $InFile line] != -1} {

it returns

can not find channel name "file3"

why can it not find that channel? The file is still open and it's opened for
read in the line directly before the while statement?

Any help from the Tcl/Tk experts out there?



Wed, 16 Aug 2006 04:18:36 GMT  
 Extreme beginner experiencing problems with reading files

Quote:

> My code goes something like

> set FileList [GrabFiles /home]
> foreach File $FileList {
>     set InFile [open $File r]
>         while {[gets $InFile line] != -1} {
>             if {[string first "<BODY>" $line] != -1} {
>                 rest of code

> My problem is when it gets to the

> while {[gets $InFile line] != -1} {

> it returns

> can not find channel name "file3"

> why can it not find that channel? The file is still open and it's opened for
> read in the line directly before the while statement?

Do you see this error on the first iteration of the loop or a subsequent
iteration? Could it be that somewhere in "rest of code" the channel is
being closed, or InFile is being set to something different?


Wed, 16 Aug 2006 04:54:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. TASUG - Extreme Programming - Experience an Extreme Hour

2. Help, Extreme Beginner, what do I need?

3. PROBLEM: Binary file reading problems

4. PROBLEM: Binary file reading problems

5. beginner experiences

6. PYTHON: problem using file.write method (stupid, beginner)

7. Beginner experience with Verilog

8. Problem reading clarion 2 files with clarion version 5

9. Problem reading some dbaseIII Files

10. Problem reading fields in a Btrieve file with the process template

11. Problem reading MS Access file with C55PE

12. read two sets of data from two spread sheet files to two arrays problem

 

 
Powered by phpBB® Forum Software