function CheckPID(pid: string): boolean;
var
i: integer;
nMod, nValue, cv: integer;
snmod: string;
begin
pid := replacestr(pid, '-', '');
result := false;
if length(replacestr(pid, ' ', '')) <> 13 then
exit;
try
cv := strtoint(copy(pid, 1, 1));
nValue := cv * 13;
for i := 2 to 12 do
begin
cv := strtoint(copy(pid, i, 1));
nValue := nValue + (cv * (14 - i));
end;
nMod := 11 - (nValue mod 11);
snmod := inttostr(nmod);
snmod := copy(snmod, length(snmod), 1);
result := copy(pid, 13, 1) = snmod;
except
result := false;
end;
end;