flaw in th script to be seen

Status
Not open for further replies.

sun_ray

Advanced Member level 3
Joined
Oct 3, 2011
Messages
772
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Visit site
Activity points
6,828
Hello following is a piece of code that compare two files named m1 and f1 and searches for a string that contain 'circuit1' in m1 and see if similar string consisting of string1 is there in f1. If I run the script I get a warning that extra character after close brace at the line that contain while {[gets $master_file line] >= 0 }{. Can you please where is the flaw that such a warning comes?


proc comparison {m1 f1} {

set master_file [open $m1 r]
set compare_file [open $f1 r]

set masterlist {}
set comparelist {}
set result {}

while {[gets $master_file line] >= 0 }{
if {[regexp {circuit1} $line]}{
lappend masterlist $line
}
}

while {[gets $compare_file line] >= 0 }{
if {[regexp {circuit1} $line]}{
lappend comparelist $line
}
}

for {set i 0} { $i< [llength $comparelist]} { incr i} {
for {set j 0} {$j < [llength $masterlist] } {incr j} {
lappend result [string compare [lindex $comparelist $i] [lindex $masterlist $j]]
}
set comp_var [lsearch $result "1"]
if {$comp_var eq -1} {
puts "[lindex $comparelist $i]"
}
set result {}
}
close $master_file
close $compare_file
}
comparison file1 file2
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…