How to dynamically pass operators to if?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

How to dynamically pass operators to if?

From: Andrew Falanga <not_real@hp.com>
Date: Wed Mar 08 2006 - 16:54:56 CET

Hi,

I have a situation where I'm trying to pass the comparison operator
dynamically to a conditional. Something like this,

proc myproc { args } {
   # pull out of args what I need which, among other things will be
   # a couple of values for a comparison operation in an if conditional

   if { $val1 $oper $val2 } {
      # do lots of important stuff
   }
}

when this executes, I get this error.

syntax error in expression " $val1 $oper $val2 ": extra tokens at end of
expression

So, how would I make this happen?

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled. I do not wish my account at HP to
become a spam haven.
Received on Sun Apr 30 02:27:29 2006