-
Notifications
You must be signed in to change notification settings - Fork 4
/
TCL script to find the difference between the two strings.tcl
48 lines (47 loc) · 1.51 KB
/
TCL script to find the difference between the two strings.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#Written by : Udaya Shankar S
#dated: 9.11.2022
#TCL script to find the difference between the two strings (str1 & str2)
#Version 1.0
set str1 "Tcl is a cross platform language with full unicode support."
set str2 "Tcl is an direct platform language with full support."
set a [split $str1]
set b [split $str2]
if {[llength $a] == [llength $b]} {
for {set i 0 } {$i < [llength $a] } {incr i} {
for {set j 0} {$j < [llength $b] } {incr j} {
if {[lindex $a $i] == [lindex $b $i]} {
puts "Strings a & b are equal at $i"
break
} else {
puts "Strings a & b are notequal at $i"
break
}
}
}
} elseif {[llength $a] > [llength $b]} {
for {set i 0 } {$i < [llength $a] } {incr i} {
for {set j 0} {$j < [llength $a] } {incr j} {
if {[lindex $a $i] == [lindex $b $i]} {
puts "Strings a & b are equal at $i"
break
} else {
puts "Strings a & b are notequal at $i"
break
}
}
}
} elseif {[llength $a] < [llength $b]} {
for {set i 0 } {$i < [llength $b] } {incr i} {
for {set j 0} {$j < [llength $b] } {incr j} {
if {[lindex $a $i] == [lindex $b $i]} {
puts "Strings a & b are equal at $i"
break
} else {
puts "Strings a & b are notequal at $i"
break
}
}
}
} else {
puts "Strings a and b are different"
}