Standard Pascal requires that case constants be specified individually. When the constant ranges extension is enabled, you can use constant ranges to specify a number of consecutive case constants. To use a constant range you specify the first constant in the range, and the last constant in the range, separated by .. as follows:
first..last
You could use the constant range
1..5
to specify the following case constants
1, 2, 3, 4, 5
For example suppose c is a variable of char type and you want to use a case statement to write the word Letter if c contains a letter, and the word Digit if c contains a digit, then you could specify each case constant individually as follows:
case c of
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
: write('Letter');
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
: write('Digit');
end;
Or you could use constant ranges like the following:
case c of
'a'..'z', 'A'..'Z'
: write('Letter');
'0'..'9'
: write('Digit');
end;
Constant ranges can be used in case statement, like in the example above, and in variant record types.