Hi There, I want to compare to strings to each other. My code:
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
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
}
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