Delphi: How to have an non-contiguous enumeration type of subbands?

While the following subband enumeration declaration is being executed:

type
   TReceiptCode = 'A'..'F';

It does not mean:

type
   TReceiptCode = ' ','A'..'F', 'R';

Does not

type
    TReceiptCode = ' ','A','B','C','D','E','F','R';

How can I declare a subband type with non-contiguous values?

+3
source share
3 answers

Unfortunately, I do not think this can be done. You can declare a (new) non-contiguous enumeration or sub-range of an existing type, but not both.

+5
source

Could you use the kit?

TSomeCharSet= Set of Char;

SomeChars: TSomeCharSet = [' ','A','B','C','D','E','F','R'];

Maybe a grandmother and an egg, but I'm not sure what you are using then for :))

, , , TNonContigousCharRange , Set array "Range" , SetReceiptCode, .

+4

In all the previous answers, I would simply add that the key is in a type name: sub range

Simply put, a range has a lower and upper limit. What you are describing is a collection (or a subset), not a subband, so of course you cannot express it as a subband.

+3
source

Source: https://habr.com/ru/post/1719733/


All Articles