August 1999
Intermediate to advanced
1488 pages
72h 53m
English
switch(expression){
case label1:
code;
break;
case label2:
code;
break;
case labelN:
code;
break;
default:
code;
}
The switch statement allows you to process the expression passed by matching it with a label—from label1 to labelN. If there is a match, the code following that label is executed. If the expression passed does not match a label, the default section is executed. Note that you can have as many labels as you deem necessary in your script.
Listing 6.262 has a text field and a button. Users are asked to enter a day of the week into the field. When they press the button, a function is called that contains a switch, which verifies they entered a correct ...
Read now
Unlock full access