Re: Weird Error Msg
- From: "SuNnY" <esunny@xxxxxxxxx>
- Date: 5 Feb 2007 17:17:10 -0800
On Feb 6, 1:57 am, Bryan Oakley <oak...@xxxxxxxxxxxxxxxxxxxx> wrote:
SuNnY wrote:
here is what i have done so far, it is not complete, not at all but i
am working my way out.
cd "C:\\"
set RootDir [pwd]
puts "Root: [pwd]"
set txtfile [glob -nocomplain *.tcl]> ...
set DirList [glob -directory $RootDir *]
puts "Dir List : $DirList"
foreach Dir $DirList {
set txtfile [glob -nocomplain *.tcl]
foreach file $txtfile {
puts "Searching file $file Textdata ....."
set Rdfile [open $file r]
while { [eof $Rdfile]!=1 } {
set TestStr [gets $Rdfile]
foreach Str $TestStr {
The above statement is your problem. You are reading lines of data from
a text file and assuming each line is a valid tcl list. It almost
certainly is not.
If you are trying to parse a tcl file and print out commands or
variables or something, that is not something you can do with a simple
loop. You'll need to mimic the behavior of the tcl interpreter with
respect to quotes, curly braces, backslashes and newlines.
If all you're doing is looking for a string within a line in the file,
there is no need to do the "foreach Str $TestStr", you can just use
something like "string match $pattern $TestStr" or "regexp $pattern
$TestStr" or "string first $pattern $TestStr", depending on whether you
want to match a glob-style pattern, a regular expression, or a fixed string.
I am trying to read a particular string from a particular type of
file.
there are many files of this type.
and i am looking for this string in these particular files only.
So i need to scan complete directory tree to search for this file,
then to check if this particular string is present or not. if yes then
to display string with count (count=number of times this string
appears in all the files)
That is why i need to read the contents of the directory and the
files.
Now i am trying it using glob -type.
.
- Follow-Ups:
- Re: Weird Error Msg
- From: Bryan Oakley
- Re: Weird Error Msg
- From: Bruce Hartweg
- Re: Weird Error Msg
- References:
- Weird Error Msg
- From: SuNnY
- Re: Weird Error Msg
- From: Bryan Oakley
- Re: Weird Error Msg
- From: SuNnY
- Re: Weird Error Msg
- From: Bryan Oakley
- Re: Weird Error Msg
- From: SuNnY
- Re: Weird Error Msg
- From: Bryan Oakley
- Weird Error Msg
- Prev by Date: Re: Weird Error Msg
- Next by Date: Re: Tcl bytecode
- Previous by thread: Re: Weird Error Msg
- Next by thread: Re: Weird Error Msg
- Index(es):
Relevant Pages
|