Re: Weird Error Msg



On Feb 5, 8:32 pm, Bryan Oakley <oak...@xxxxxxxxxxxxxxxxxxxx> wrote:
SuNnY wrote:
On Feb 5, 6:34 pm, Bryan Oakley <oak...@xxxxxxxxxxxxxxxxxxxx> wrote:
SuNnY wrote:
Hi all !!
I am working on file and string searching. while executing my code , i
am getting this strange error msg. i tried everything but cudnt crack
what tclsh is trying to tell me ...
here is the complete error msg:
list element in quotes followed by "." instead of space
while executing
"foreach Str $TestStr {
"List element in quotes followed by <some character>" means the variable
doesn't contain a valid list (by virtue of it having a non-whitespace
character immediately after a quoting character).

My guess is, you're taking a random string from a file or from user
input and are trying to use it as a Tcl list, which you should not be doing.

--
Bryan Oakleywww.tclscripting.com

Hi !!

Well yes, i have to search for a particular string in a directory. my
idea is to search for particular type of file, and search for
particular string in each file.
But when while searching for files in a directory, the program stops
when it encounters more than one "." in the file/directory name. I try
to catch the list of the files in a list and then by using foreach i
am reading and searching file for particular string.

How to over come this ? problem

You aren't showing us your actual code. The problem you are trying to
solve is trivial, but apparently the way you are going about it is not.

How are you doing the "search for particular type of file" part of the
algorithm? You should probably be using the "glob" command, but I'm
guessing you're not since the "list" of files you are iterating over
isn't a valid list.

Step one in us helping you solve the problem is to show us how you are
computing the list of files you are iterating over.



Also can someone guide me to complete documentation on file searching
( not the content of file)

http://www.tcl.tk/man/tcl8.4/TclCmd/glob.htm

--
Bryan Oakleywww.tclscripting.com


Hi !!

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] ;# To change
Root dir
puts "Root: [pwd]"

set txtfile [glob -nocomplain *.tcl] ;# Search
of .tcl file
set DirList [glob -directory $RootDir *] ;# Gets list of
files/directories and stores in DirList variable
puts "Dir List : $DirList" ;# Dispaly
the list of directories/file of current directory

foreach Dir $DirList {

if { [file isdirectory $Dir] } { ;# checks if
it is a Directory or file
cd "$Dir" ;# changes
to next level directory
puts "Current Dir : [pwd]"

set txtfile [glob -nocomplain *.tcl] ;# Search of .tcl
file
foreach file $txtfile {
puts "Searching file $file Textdata ....."
set Rdfile [open $file r]
while { [eof $Rdfile]!=1 } {
set TestStr [gets $Rdfile]
foreach Str $TestStr {
set result [string match ABC $Str]
puts "checking result"
if {$result==1} {
puts "Match :$result"
}
} ;# end of foreach
} ;# end of while
} ;#
end of foreach
} else {
puts "$Dir : Its not a directory"
} ;# end of if-else
} ;#
end of foreach
} ;#
end of main
main

thnx for the link abt glob and file handling.

.



Relevant Pages

  • Re: Weird Error Msg
    ... "foreach Str $TestStr { ... i have to search for a particular string in a directory. ... But when while searching for files in a directory, ... to catch the list of the files in a list and then by using foreach i ...
    (comp.lang.tcl)
  • Re: Weird Error Msg
    ... foreach file $txtfile { ... puts "Searching file $file Textdata ....." ... want to match a glob-style pattern, a regular expression, or a fixed string. ...
    (comp.lang.tcl)
  • Re: Weird Error Msg
    ... foreach file $txtfile { ... puts "Searching file $file Textdata ....." ... want to match a glob-style pattern, a regular expression, or a fixed string. ...
    (comp.lang.tcl)
  • Re: String searching and lienar optimization
    ... There are *lots* of things known about pattern matching. ... string: "fjwkrjweoriosdaicfosdifidoiasosifosdifosdfio" for example.. ... Can this problem be posed suitable lfor linear optimization? ... What I am trying to do is to structure a string searching ...
    (sci.math.num-analysis)
  • RE: Oject value changing in a loop
    ... Sub zString_FindGeneral(ByRef IFindThis As String, ... ByRef IFmRow As Long, ByRef IFmCol As Integer, ByRef IToRow As Long, ByRef ... ' OFoundQty is the number of cells found containing the IFindThis string. ... 'Lines A, D, E work when searching one or multiple worksheets ...
    (microsoft.public.excel.programming)