An welcher Stelle wird der Fehler angezeigt?
In PascalScript funktioniert diese Variante:
Delphi-Quellcode:
function longestNumber(s : string) : byte;
var run, number : byte;
begin
Result := 0;
number := 0;
for run := 1 to length(s) do
begin
case s[run] of
'0'..'9' : number := number + 1;
else
begin
if number > Result then Result := number;
number := 0;
end;
end;
end;
if number > Result then Result := number;
end;
Oder alternativ:
Delphi-Quellcode:
function longestNumber(s : string) : byte;
var run, number, longNum : byte;
begin
longNum := 0;
number := 0;
for run := 1 to length(s) do
begin
case s[run] of
'0'..'9' : inc(number);
else
begin
if number > longNum then longNum := number;
number := 0;
end;
end;
end;
if number > longNum then longNum := number;
longestNumber := longNum;
end;