Problem with a piece of code (probably a simple one) 
Author Message
 Problem with a piece of code (probably a simple one)

while {$temp_var < 0 } {
   incr tics
   gets $input_file current_line
   set temp_var [lsearch $current_line $string_var]

Quote:
}

when I use this I get the error:

unmatched open brace in list while executing "lsearch $curren_line
$string_var" ("while" body line 4) invoked from within
"while {$temp_var < 0 } {
   incr tics
   gets $input_file current_line
   set temp_var [lsearch $current_line $string_var]

Quote:
}"



Sun, 24 Nov 2002 03:00:00 GMT  
 Problem with a piece of code (probably a simple one)

Quote:

>while {$temp_var < 0 } {
>   incr tics
>   gets $input_file current_line
>   set temp_var [lsearch $current_line $string_var]
>}

>when I use this I get the error:

>unmatched open brace in list while executing "lsearch $curren_line
>$string_var" ("while" body line 4) invoked from within
>"while {$temp_var < 0 } {
>   incr tics
>   gets $input_file current_line
>   set temp_var [lsearch $current_line $string_var]
>}"

It's doing what you ask.

What do you really want?  Are you trying to find the
first line which contains $string_var?  Depending on
the contents of $string_var, you might prefer the
functionality of

  set found 0
  while {!$found} {
      incr tics
      if {-1 == [gets $input_file current_line]} {
          do_something_because_we_read_the_whole_file
      }
      set found [regexp $string_var $current_line]
  }
--


Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



Sun, 24 Nov 2002 03:00:00 GMT  
 Problem with a piece of code (probably a simple one)

Quote:
> while {$temp_var < 0 } {
>    incr tics
>    gets $input_file current_line
>    set temp_var [lsearch $current_line $string_var]
> }

> when I use this I get the error:

> unmatched open brace in list while executing "lsearch $curren_line
> $string_var" ("while" body line 4) invoked from within
> "while {$temp_var < 0 } {
>    incr tics
>    gets $input_file current_line
>    set temp_var [lsearch $current_line $string_var]
> }"

This message is telling you, in effect, that the line of data you just read
in is not a valid tcl list.

The solution? Don't assume data you read from stdin is a well formed tcl
list. Use a string based command rather than lsearch, since lsearch requires
a well formed list to be searched.



Sun, 24 Nov 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Probably a simple one

2. probably a simple problem

3. Problem (probably simple) that I can't solve

4. Help! Probably a simple problem

5. Problem with Menu generation, probably a dumb one ...

6. How to replace one or two words with one word with one line of awk code

7. One piece EXE

8. Something probably simple...

9. I have a very simple..probably stupid..clipper question

10. Probably a simple newbie question...

11. Bug ... probably another one

12. Probably a simple question

 

 
Powered by phpBB® Forum Software