tomdagliusa
Programmer
I have some variables I have defined in a global values file. I want to use them as switch points in a switch command, but I can't get it to work.
The following type of code works:
switch -exact -- $port {
"1" {set if 400}
"2" {set if 500}
}
BUT, I don't want to hardwire the switch to values 1 and 2.
If I try to reference the variables, it doesn't work.
For instance:
switch -exact -- $port {
"$PORT_A" {set x 400}
"$PORT_B" {set x 500}
}
This method allows me to pre-set PORT_A and _B to whatever I need and not hardwire them to 1 or 2, BUT the switch falls thru and doesn't seem to recognize either. The variables port, PORT_A, and PORT_B are all declared so it's not that it can't "see" those vars.
Confused,
Tom
The following type of code works:
switch -exact -- $port {
"1" {set if 400}
"2" {set if 500}
}
BUT, I don't want to hardwire the switch to values 1 and 2.
If I try to reference the variables, it doesn't work.
For instance:
switch -exact -- $port {
"$PORT_A" {set x 400}
"$PORT_B" {set x 500}
}
This method allows me to pre-set PORT_A and _B to whatever I need and not hardwire them to 1 or 2, BUT the switch falls thru and doesn't seem to recognize either. The variables port, PORT_A, and PORT_B are all declared so it's not that it can't "see" those vars.
Confused,
Tom