Hi Guys
Need some help on the following please.
I use a mine design program called SURPAC. In this i have a string file. I want to see if the first and last point of each segment correspond thus puts "CLOSED" if not puts "OPEN"
Attached find example of string data and code thus far:
String File:
boundary,17-Jun-10,,SSI_STYLES:styles.ssi
0, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000
1, 10.892, -21.459, 0.000,
1, -162.709, 302.010, 0.000,
1, -223.824, 262.159, 0.000,
1, -136.770, 59.766, 0.000,
1, -122.366, 6.236, 0.000,
1, -3.786, -72.817, 0.000,
1, 10.892, -21.459, 0.000,
0, 0.000, 0.000, 0.000,
1, -421.239, -423.305, 0.000,
1, -246.459, -382.383, 0.000,
1, -236.858, -267.726, 0.000,
1, -287.289, -135.515, 0.000,
1, -472.920, -50.802, 0.000,
1, -552.803, -159.236, 0.000,
1, -515.960, -332.622, 0.000,
1, -422.239, -423.305, 0.000,
0, 0.000, 0.000, 0.000,
2, -50.128, -225.473, 0.000,
2, -3.786, -72.817, 0.000,
2, -122.366, 6.236, 0.000,
2, -242.310, -30.565, 0.000,
2, -287.289, -135.515, 0.000,
2, -236.858, -267.726, 0.000,
2, -50.128, -225.473, 0.000,
0, 0.000, 0.000, 0.000,
2, -677.461, -67.385, 0.000,
2, -515.960, -332.622, 0.000,
2, -552.803, -159.236, 0.000,
2, -472.920, -50.802, 0.000,
2, -394.755, 189.859, 0.000,
2, -678.461, -67.385, 0.000,
0, 0.000, 0.000, 0.000,
3, -209.483, -376.749, 0.000,
3, -50.128, -225.473, 0.000,
3, -236.858, -267.726, 0.000,
3, -246.459, -382.383, 0.000,
3, -209.483, -376.749, 0.000,
0, 0.000, 0.000, 0.000,
3, -136.770, 59.766, 0.000,
3, -223.824, 262.159, 0.000,
3, -394.755, 189.859, 0.000,
3, -472.920, -50.802, 0.000,
3, -287.289, -135.515, 0.000,
3, -242.310, -30.565, 0.000,
3, -122.366, 6.236, 0.000,
3, -136.770, 59.766, 0.000,
0, 0.000, 0.000, 0.000,
0, 0.000, 0.000, 0.000, END
Script :
set fimp [open "boundary.str" "r"]
gets $fimp line
gets $fimp line
set check 0
while {[gets ${fimp} line] >= 0} {
if {[string is double [lindex [split $line ","] 0]] && [lindex [split $line ","] 0] > 0 && [lindex [split $line ","] 0] != ""} {
set line [split $line ","]
switch -exact -- $check {
"0" {set next $line}
"1" {set prev $prev}
}
set prev $line
set check 1
} else {
set prev $prev
set next $next
if {[lindex $prev 1] == [lindex $next 1]} {
puts ""
puts "String [lindex $prev 0] Segment is CLOSED"
}
if {[lindex $prev 1] != [lindex $next 1]} {
puts ""
puts "String [lindex $next 0] first point \[[lindex $next 1];[lindex $next 2];[lindex $next 3]] is different from"
puts "String [lindex $prev 0] last point \[[lindex $prev 1];[lindex $prev 2];[lindex $prev 3]]"
puts "String [lindex $next 0] Segment is OPEN"
}
set check 0
}
}
close $fimp
Problems:
1. Need to specify not only that the string is "OPEN" but which segment it is.
2. Last segment gets duplicated as closed or open.
Need some help on the following please.
I use a mine design program called SURPAC. In this i have a string file. I want to see if the first and last point of each segment correspond thus puts "CLOSED" if not puts "OPEN"
Attached find example of string data and code thus far:
String File:
boundary,17-Jun-10,,SSI_STYLES:styles.ssi
0, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000
1, 10.892, -21.459, 0.000,
1, -162.709, 302.010, 0.000,
1, -223.824, 262.159, 0.000,
1, -136.770, 59.766, 0.000,
1, -122.366, 6.236, 0.000,
1, -3.786, -72.817, 0.000,
1, 10.892, -21.459, 0.000,
0, 0.000, 0.000, 0.000,
1, -421.239, -423.305, 0.000,
1, -246.459, -382.383, 0.000,
1, -236.858, -267.726, 0.000,
1, -287.289, -135.515, 0.000,
1, -472.920, -50.802, 0.000,
1, -552.803, -159.236, 0.000,
1, -515.960, -332.622, 0.000,
1, -422.239, -423.305, 0.000,
0, 0.000, 0.000, 0.000,
2, -50.128, -225.473, 0.000,
2, -3.786, -72.817, 0.000,
2, -122.366, 6.236, 0.000,
2, -242.310, -30.565, 0.000,
2, -287.289, -135.515, 0.000,
2, -236.858, -267.726, 0.000,
2, -50.128, -225.473, 0.000,
0, 0.000, 0.000, 0.000,
2, -677.461, -67.385, 0.000,
2, -515.960, -332.622, 0.000,
2, -552.803, -159.236, 0.000,
2, -472.920, -50.802, 0.000,
2, -394.755, 189.859, 0.000,
2, -678.461, -67.385, 0.000,
0, 0.000, 0.000, 0.000,
3, -209.483, -376.749, 0.000,
3, -50.128, -225.473, 0.000,
3, -236.858, -267.726, 0.000,
3, -246.459, -382.383, 0.000,
3, -209.483, -376.749, 0.000,
0, 0.000, 0.000, 0.000,
3, -136.770, 59.766, 0.000,
3, -223.824, 262.159, 0.000,
3, -394.755, 189.859, 0.000,
3, -472.920, -50.802, 0.000,
3, -287.289, -135.515, 0.000,
3, -242.310, -30.565, 0.000,
3, -122.366, 6.236, 0.000,
3, -136.770, 59.766, 0.000,
0, 0.000, 0.000, 0.000,
0, 0.000, 0.000, 0.000, END
Script :
set fimp [open "boundary.str" "r"]
gets $fimp line
gets $fimp line
set check 0
while {[gets ${fimp} line] >= 0} {
if {[string is double [lindex [split $line ","] 0]] && [lindex [split $line ","] 0] > 0 && [lindex [split $line ","] 0] != ""} {
set line [split $line ","]
switch -exact -- $check {
"0" {set next $line}
"1" {set prev $prev}
}
set prev $line
set check 1
} else {
set prev $prev
set next $next
if {[lindex $prev 1] == [lindex $next 1]} {
puts ""
puts "String [lindex $prev 0] Segment is CLOSED"
}
if {[lindex $prev 1] != [lindex $next 1]} {
puts ""
puts "String [lindex $next 0] first point \[[lindex $next 1];[lindex $next 2];[lindex $next 3]] is different from"
puts "String [lindex $prev 0] last point \[[lindex $prev 1];[lindex $prev 2];[lindex $prev 3]]"
puts "String [lindex $next 0] Segment is OPEN"
}
set check 0
}
}
close $fimp
Problems:
1. Need to specify not only that the string is "OPEN" but which segment it is.
2. Last segment gets duplicated as closed or open.