WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Switch Statement - Multiple Values Under One Case

Keywords: 

Question:

I need help on using the switch statement.

What I want to do is to have multiple values under one case. So if the the result of the case is 1, 2 or 3 I want it to execute the same set of commands, rather than typing those commands out three times under a seperate case each time.

At the moment my code looks like this :-

Switch directory
Case 1
directory = "/home/columbus"
break
Case 5
directory = "/home/columbus"
break
Case 6
directory = "/home/columbus"
break
End Switch
This code works, but there is a lot of repetition. I would like to make it smaller.

At first I tired this :-

Switch directory

Case 1, 5, 6
directory = "/home/columbus"
break

End Switch
The result was an error code "3074: Expression continues past expected end" on the line "Case 1, 5, 6". Is there anyway to achieve want I want ?

Thanks.

Answer:

Try:
Switch directory
Case 1
Case 5
directory = "/home/columbus"
break
etc...
Article ID:   W14234
Filename:   Switch Statement - Multiple Values Under One Case.txt
File Created: 1999:10:26:11:22:40
Last Updated: 1999:10:26:11:22:40