Posted to tcl by sebres at Mon Apr 27 11:37:00 GMT 2020view raw
- set var1 {YNC 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}
- # some secret logic (at the moment returns 0 first 2 times called and always 1 hereafter):
- set i 0
- proc secret_knowledge {} {upvar i i; expr {[incr i] > 2}}
- set var1 [split $var1 ";"]
- set var2 [split $var2 ";"]
- set res {}
- foreach v $var2 {
- if {[regexp {^SYNC } $v] && [secret_knowledge]} {
- lappend res NOOP
- }
- lappend res $v
- if {[regexp {^SYNC } $v] && [secret_knowledge]} {
- lappend res NOOP
- }
- }
- puts "expect:\tSYNC 1 2;K2_SP4_CHECK_DIAMETER UGT010_0232;NOOP;SYNC 2 2;NOOP"
- puts "result:\t[join $res ";"]"