Posted on 2008-11-20 21:03:48-08 by cerr
string search
Hi There, I want to compare to strings to each other. My code:
while {!$cond} { #set NewStr [.serialMon.cons get MyMark end] ;#load content from console window into $ +str $GUI::twidget insert end "\n NewStr: $serial::rxBuffer!!\n" error $GUI::twidget see end set lst [split $serial::rxBuffer \n\r] ;#load content into list set length [llength $lst] .serialMon.cons insert end "\n\n******ListLength: $length*****\n\n" if {$length<1} { set str1 [lindex $lst [$length-1]] set str2 [lindex $lst $length] if {string compare -length 10 $str1 $str2 == 0} ;#see if the last two strings match set $cond 1 ;#set stop condition }
But the interpreter is telling me following syntax error in expression "string compare -length 10 $str1 $str2 == 0": variable references require preceding $ syntax error in expression "string compare -length 10 $str1 $str2 == 0": variable references require preceding $ ("if" test expression) while compiling "if {string compare -length 10 $str1 $str2 == 0} " ("if" then script line 4) while compiling "if {$length<1} { set str1 [lindex $lst [$length-1]] set str2 [lindex $lst $length] if {string compare -length 10 $st..." ("while" body line 8) while compiling "while {!$cond} { #set NewStr [.serialMon.cons get MyMark end] ;#load content from console window into $str $GUI::twidget inser..." And I have no clue why, help would be appreciated! Thank you very much! Ron
Direct Responses: 9381 | Write a response
Posted on 2008-11-20 23:05:09-08 by eserte in response to 9379
Re: string search
I think you're in the wrong forum. This one is about the *Perl* module named Tcl::Tk (a bridge between Perl and Tcl/Tk).

Regards, Slaven
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.