Your definition is close, but it's not quite right:
type
TCapitalLetter = 'A'..'Z';
TDigit = '0'..9';
From your other question, though, I don't think that's what you really need to do. You're looking for membership (some character being contained in that type), in which case you need to do it using sets. It's a console application you can just compile and test:
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
type
TCapitalLetters = TSysCharSet;
TDigits = TSysCharSet;
const
CapitalLetters: TCapitalLetters = ['A'..'Z'];
Digits: TDigits = ['0'..'9'];
var
Temp, Output: string;
Ch: Char;
begin
Output := '';
Temp := 'Seems A Nice Test Answer';
for Ch in Temp do
if CharInSet(Ch, CapitalLetters) then
Output := Output + Ch;
WriteLn(Output);
ReadLn;
end.
For earlier (non-Unicode) versions of Delphi, you need to use set of Char
instead of TSysCharSet
, and use a slightly different syntax for the set membership:
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
type
TCapitalLetters = set of Char;
TDigits = set of Char;
const
CapitalLetters: TCapitalLetters = ['A'..'Z'];
Digits: TDigits = ['0'..'9'];
var
Temp, Output: string;
Ch: Char;
begin
Output := '';
Temp := 'Seems A Nice Test Answer';
for Ch in Temp do
if Ch in CapitalLetters then
Output := Output + Ch;
WriteLn(Output);
ReadLn;
end.
Output of test app: