
comparing multiple list lengths
Quote:
> I'm comparing list_length_1 with list_length_2, then outputting a fault
> message if mismatch.
> I then compare list_length_1 with list_length_3, then outputting a
> fault message,
> and then compare list_length_1 with list_length_4, then outputting a
> fault message.
if {$list_length1 != $list_length2 || \
$list_length1 != $list_length3 || \
$list_length1 != $list_length4
} {
puts "Error in lists, unix list not same length as PC_ID list"
puts ""
puts "press Enter to exit"
gets stdin garbage
exit
}
Quote:
> which i then repeat for lists 3 & 4. I cant seem to get the OR
> function to work, I've tried all sorts of combinations, all to no avail
> so far! I only need one error message to say all 4 lists are not equal
> length.
Using OR will mean "if any list is not equal", if you really want to
mean "all lists are not equal" you must use AND:
if {$list_length1 != $list_length2 && \
$list_length1 != $list_length3 && \
$list_length1 != $list_length4
} {
puts "Error in lists, unix list not same length as PC_ID list"
puts ""
puts "press Enter to exit"
gets stdin garbage
exit
}
Actually, even this does not mean "all 4 lists are not equal", it
simply means "all lists are not equal to list_length1". If you really
want to do what you say you mean, you need:
if {$list_length1 != $list_length2 && \
$list_length1 != $list_length3 && \
$list_length1 != $list_length4 && \
$list_length2 != $list_length3 && \
$list_length2 != $list_length4 && \
$list_length3 != $list_length4
} {
puts "Error in lists, unix list not same length as PC_ID list"
puts ""
puts "press Enter to exit"
gets stdin garbage
exit
}