While the following subrange enumeration declaration works:
type
TReceiptCode = 'A'..'F';
This does not:
type
TReceiptCode = ' ','A'..'F', 'R';
Nor does
type
TReceiptCode = ' ','A','B','C','D','E','F','R';
How can i declare a subrange type with non-contiguous values?
Unfortunately, I don't think there's any way to do that. You can declare a (new) non-contiguous enumeration, or a subrange of an existing type, but not both.
Could you use a set instead?
TSomeCharSet= Set of Char;
SomeChars: TSomeCharSet = [' ','A','B','C','D','E','F','R'];
Could be granny and egg situation but I'm not sure what you are using then for :) ...
Well all you are left with then is creating TNonContigousCharRange yourself using a Set or array as the limiting "Range" and raising an exception when it is out of range or having a SetReceiptCode procedure to do a similar thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With