function Zahl2Wort(Zahl: Integer): string;
const
coZehnerWoerter: array [1..9] of string = ('zehn', 'zwan', 'drei', 'vier', 'fünf',
'sech', 'sieb', 'acht', 'neun');
coEinerWoerter: array [1..9] of string = ('ein', 'zwei', 'drei', 'vier', 'fünf',
'sechs', 'sieben', 'acht', 'neun');
{------------------------------------------------------------------------------}
function GetGroup(aHunderter, aZehner, aEiner, GroupIndex: Integer): string;
begin
Result := '';
if aHunderter > 0 then
begin
Result := coEinerWoerter[aHunderter] + 'hundert'
end;
if aEiner > 0 then
begin
if (aZehner = 1) and (aEiner = 1) then
begin
if aHunderter > 0 then Result := Result + 'undelf'
else
Result := Result + 'elf';
end
else if (aZehner = 1) and (aEiner = 2) then
begin
if aHunderter > 0 then Result := Result + 'undzwölf'
else
Result := Result + 'zwölf';
end
else
Result := Result + coEinerWoerter[aEiner];
end;
if (aZehner > 0) and not ((aZehner = 1) and
((aEiner = 2) or (aEiner = 1))) then
begin
if aZehner > 1 then Result := Result + 'und';
if aZehner = 3 then Result := Result + coZehnerWoerter[aZehner] + 'ßig'
else
Result := Result + coZehnerWoerter[aZehner];
if (aZehner > 1) and not (aZehner = 3) then Result := Result + 'zig'
end;
case GroupIndex of
1:
begin
if (aEiner = 1) and (aZehner = 0) then Result := Result + 's';
end;
2: Result := Result + 'tausend';
3:
begin
if (aEiner = 1) and (aZehner = 0) and (aHunderter = 0) then
Result := Result + 'emillionen'
else
Result := Result + 'millionen';
end;
4:
begin
if (aEiner = 1) and (aZehner = 0) and (aHunderter = 0) then
Result := Result + 'emilliarde'
else
Result := Result + 'milliarden';
end;
end;
end;
{------------------------------------------------------------------------------}
var
Einer, Zehner, Hunderter, GroupCount, ZahlLength: Integer;
Dummy: string;
begin
Result := '';
Dummy := IntToStr(Zahl);
ZahlLength := Length(Dummy);
GroupCount := StrToInt(FloatToStr(RoundUp(ZahlLength / 3, 0)));
while (Length(Dummy) mod 3) > 0 do
Dummy := '0' + Dummy;
while GroupCount > 0 do
begin
// Hunderter
Hunderter := StrToInt(Copy(Dummy, 1, 1));
System.Delete(Dummy, 1, 1);
// Zehner
Zehner := StrToInt(Copy(Dummy, 1, 1));
System.Delete(Dummy, 1, 1);
// Einer
Einer := StrToInt(Copy(Dummy, 1, 1));
System.Delete(Dummy, 1, 1);
Result := Result + GetGroup(Hunderter, Zehner, Einer, GroupCount);
Dec(GroupCount);
end;
Result[1] := Char(Ord(Result[1]) - 32);
end;
|