Posted to tcl by sebres at Mon Apr 27 12:11:39 GMT 2020view raw
- set var1 {SYNC 1 2;K1_SP4_SPA_CLEANUP_DIAMETER UGT0101_008;K1_SP4_SPA_FACING UGT0101_008;SYNC 2 2;K1_SP4_SPA_ROUGHING UGT0101_008}
- set var2 {SYNC 1 2;K2_SP4_CHECK_DIAMETER UGT010_0232;SYNC 2 2}
- set var1 [split $var1 ";"]
- set var2 [split $var2 ";"]
- set res {}
- set i 0
- foreach v2 $var2 {
- set v1 [lindex $var1 $i]
- if {[regexp {^SYNC } $v2] && $v1 ne $v2} {
- while {$i < [llength $var1] && [set v1 [lindex $var1 $i]] ne $v2} {
- lappend res NOOP
- incr i
- }
- if {$v1 ne $v2} {
- error "Unexpected: missing $v2 in var1."
- }
- }
- lappend res $v2
- incr i
- }
- while {$i < [llength $var1]} {
- lappend res NOOP
- incr i
- }
- puts "expect:\tSYNC 1 2;K2_SP4_CHECK_DIAMETER UGT010_0232;NOOP;SYNC 2 2;NOOP"
- puts "result:\t[join $res ";"]"