switch statement and numeric constants
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

switch statement and numeric constants

From: Klaus <lts-rudolph@gmx.de>
Date: Fri May 27 2005 - 11:11:37 CEST

Hi all,

I want to the same thing in tcl as the following C code:

#define VAL_A 1
#define VAL_B 2
#define VAL_C 4

int x = VAL_A|VAL_C;

switch (x & (VAL_A|VAL_C)) {
    case VAL_A: ... break;
    case VAL_A|VAL_C: break;
}

the tcl code i tried was:
set VAL_A 1
set VAL_B 2
set VAL_C 4

switch -regexp expr( x & VAL_A|VAL_C) \
     $VAL_A { } \
     $VAL_C|$VAL_C {} \

but that did not work.

I think the usage on vars as const is wrong at first. But are there
named constants in tcl???
The second is that I could not avaluate expressions as case value...

Any hint?

Bye
   Klaus
Received on Thu Sep 29 14:19:27 2005