Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arithmetic Expression Help

Status
Not open for further replies.

Tommms

Programmer
Feb 1, 2009
3
US
Hello Everyone,

I have been trying to figure out why the below expr doesn't work, but to no avail, and am hoping that one of you could shed some light on the issue.


if {$pointX < [expr ([lindex $x $m]-[lindex $x $l]) * ($pointY-[lindex $y $l])]} {
puts "hello"
}

when

[lindex $x $m] = 5
[lindex $x $l] = 1
$pointY = 3
[lindex $y $l] = 2

However, when I substitute the actual numeric value:

if {$pointX < [expr ([lindex $x $m]-1) * ($pointY-2)]} {
puts "hello"
}

The code works.

Does expr have problem evaluating [lindex... as an operand?

Thanks very much in advance.
 
Hi Everyone,

The issue is resolved.

The code above is trying to reference a non-existent element.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top