Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

TCL Switch command - test multiple variables

Alex_McShane_23
Nimbostratus
Nimbostratus

Hi -

 

I don't think that the following is possible within the TCL language but I would love to be proven wrong

 

Can the Switch statement be coded to test multiple variables simultaneously?

 

Other languages can and it avoids complex nested IF/ELSE statements

 

For example, using logical "Case" terminology to illustrate the point:-

 

Case Var-A, Var-B

 

when "string-A1" and "string-B1"

 

do action-1

 

when "string-A2" and "string-B2"

 

do action-2

 

I cannot identify corresponding Switch syntax that can accommodate the above

 

Much appreciated

 

1 REPLY 1

Stanislas_Piro2
Cumulonimbus
Cumulonimbus

Hi,

 

you can concatenate both variables like

 

switch ${a}|${b} { "string-A1|string-B1" { DO ACTION 1 } "string-A2|string-B2" { DO ACTION 2 } }