{
 This function assumes you've passed 9 char string
 that consists of numbers only
 If you haven't, it'll return False; it may also
 raise conversion and math errors.
 Too many IntToStr & StrToInt. try..excepts are due
 but I'm too lazy.
}
function CheckSin( const cSIN: string ): Boolean;
var
 iCnt,
 iTemp: Integer;
 iCheckNum: Integer;
 sNum1: string;
 sNum2: string;
 bReturn: Boolean;
begin
 { assume you're no-good freak who wants to trick this
  poore and humble function }
 bReturn := False;
 
 { I'll trim your stuff - just in case... }
 cSIN := Trim( cSIN );
 
 { check the length }
 if Length( cSIN ) = 9 ) then begin
  { get the checkNum - that's the numbet to compare to
   at the end of this function }
  iCheckNum := StrToInt( Copy( cSIN , Length( cSIN ) , 1 ) );
 
  { take 2nd, 4th, 6th and 8th digits and
   stream them in to form one number }
  sNum1 := Copy( cSIN , 2, 1 ) + Copy( cSIN , 4, 1 )
      + Copy( cSIN , 6, 1 ) + Copy( cSIN , 8, 1 );
  { and then multiplied that number by 2 }
  sNum1 := IntToStr( StrToInt ( sNum1 ) * 2 );
 
  { make a sum of all digits of this string }
  iTemp := 0;
  for iCnt := 1 to Length( sNum1 ) do begin
   iTemp := iTemp + StrToInt( Copy( sNum1, iCnt, 1 ) );
  end;
  { once again, we need to have this total as a string }
  sNum1:= IntToStr( iTemp );
 
  { phase II - take 1st, 3rd, 5th and 7th digit
   and also stream them in to form one number }
  sNum2 := Copy( cSIN , 1, 1 ) + Copy( cSIN , 3, 1 )
      + Copy( cSIN , 5, 1 ) + Copy( cSIN , 7, 1 );
 
  { make a sum of all digits of this string now }
  iTemp := 0;
  for iCnt := 1 to Length( sNum2 ) do begin
   iTemp := iTemp + StrToInt( Copy( sNum2, iCnt, 1 ) );
  end;
  { once again, we need to have this total as a string }
  sNum2:= IntToStr( iTemp );
 
  { final phase - first add numbers together }
  sNum1 := IntToStr( StrToInt( sNum1 ) + StrToInt( sNum2 ) );
 
  { and find what's left of it
   we'll take the last DIGIT our total, turn it into a
   number and take it off a 10 }
  iTemp := 10 - StrToInt( Copy( sNum1, Length( sNum1 ), 1 ) );
 
  if iTempt = 10 then
   iTemp := 0; { must be 1 digit }
 
  bReturn := ( iTemp = iCheckNum );
 end;
 
 Result := bReturn;
end;

 