Code: Alles auswählen
function intCompare(s1, s2: string) :boolean;
// compares wors on a similar content
// (c) retnyg
function reformat (s:string):string;
var l,i : integer;
begin
l:=length(s);
result := '';
for i := 1 to l do
case upcase(s[i]) of
'A'..'Z': result := result + upcase(s[i]);
'Ä','ä': result := result + 'AE';
'Ö','ö': result := result + 'OE';
'Ü','ü': result := result + 'UE';
end;
end;
type ad = array [0..26] of dword;
var
// count1, count2: ad;
// pcount: ^ad;
usedletters1: string;
usedletters2: string;
plen : pinteger;
i,l,l2:integer;
p, p2: pstring;
begin
result := false;
if (length(s1) = 0) or (length(s2) = 0) then exit;
s1:=reformat(s1);
s2:=reformat(s2);
l := length(s1);
l2 := length(s2);
// if (l * 100) div (length(s2) * 100)
plen := @l;
p := @s1;
p2 := @usedletters1;
// pcount:= @count1;
// zeromemory(pcount,sizeof(ad));
setlength(p2^,0);
for i := 1 to plen^ do begin
if pos(p^[i],p2^) = 0 then
p2^ := p2^ + p^[i];
// inc(count1[ord(p^[i])-65]);
end;
plen := @l2;
p := @s2;
p2 := @usedletters2;
// pcount:= @count2;
// zeromemory(pcount,sizeof(ad));
setlength(p2^,0);
for i := 1 to plen^ do begin
if pos(p^[i],p2^) = 0 then p2^ := p2^ + p^[i];
// inc(count1[ord(p^[i])-65]);
end;
if usedletters1 = usedletters2 then begin result := true; exit; end;
end;
Code: Alles auswählen
unit1.pas(42,14) Error: Constant and CASE types do not match
unit1.pas(42,14) Error: Ordinal expression expected
unit1.pas(42,19) Error: Constant and CASE types do not match
unit1.pas(42,19) Error: Ordinal expression expected
unit1.pas(42,19) Error: duplicate case label
unit1.pas(43,14) Error: Constant and CASE types do not match
unit1.pas(43,14) Error: Ordinal expression expected
unit1.pas(43,14) Error: duplicate case label
unit1.pas(43,19) Error: Constant and CASE types do not match
unit1.pas(43,19) Error: Ordinal expression expected
unit1.pas(43,19) Error: duplicate case label
unit1.pas(44,14) Error: Constant and CASE types do not match
unit1.pas(44,14) Error: Ordinal expression expected
unit1.pas(44,14) Error: duplicate case label
unit1.pas(44,19) Error: Constant and CASE types do not match
unit1.pas(44,19) Error: Ordinal expression expected
unit1.pas(44,19) Error: duplicate case label
unit1.pas(109) Fatal: There were 17 errors compiling module, stopping
aufgerufen wird sie z.B. mit
Code: Alles auswählen
if intCompare('Morrisette', 'moriset') then showmessage('same word');