Evaluating using expr (newbie at TCL)

greenspun.com : LUSENET : Tool Command Language (Tcl) : One Thread

I am rather new at this. Anyway, I am trying to evaluate the following: (mathematically expressed) 30 < DisbAmt < 100

I tried using nested TCL: expr [{expr [DisbAmt > 30]} < 100]

Doesn't get the results expected. Anyone can help?

Many thanks in advance.

raine

-- raine oon (raineoon@netscape.net), March 12, 1999

Answers

Sorry - I didn't know anyone had posted a question here!

You need: expr $DisbAmt > 30 && $DisbAmt < 100

The reason what you tried failed was because 1. [DisbAmt > 30] would try to execute a procedure called DisbAmt sending it 2 arguments, ">" and "30". I don't THINK that is what you meant. 2. The results of 1 would be a 1 or 0 (or an error I suspect). That return code (1, 0, or error) would then attempt to be executed - for example: 1 < 100 not as a comparison, but looking for a procedure called "1" and handing it two arguments "<" and "100".

Use [...] to list procedures or external commands you wish to execute and place the standard output results into some expression or variable.

-- Larry W. Virden (lvirden@cas.org), December 13, 1999.


Moderation questions? read the FAQ