Difference between revisions of "ISO 7064"

From Free Pascal wiki
Jump to navigationJump to search
m (Fixed syntax highlighting)
Line 7: Line 7:
 
The function StrMOD97 can encode and verify number checksum with ISO 7064 mod 97 10
 
The function StrMOD97 can encode and verify number checksum with ISO 7064 mod 97 10
  
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
  
 
function StrMOD97( s :String):integer;
 
function StrMOD97( s :String):integer;

Revision as of 08:14, 18 February 2020

English (en) français (fr)

ISO 7064 specifies a set of check character systems capable of protecting strings against errors which occur when people copy or key data.

Function StrMOD97

The function StrMOD97 can encode and verify number checksum with ISO 7064 mod 97 10

function StrMOD97( s :String):integer;
const
  modu = 97;
var
  sx :String;
  isx,ic,p:Integer;
begin
   p := Length( s );
   while( p > 9 ) do
     begin
       sx := Copy( s, 1, 9 );
       Delete( s, 1, 9 );
       isx := StrToInt( sx );
       ic := isx mod modu;
       s := IntToStr( ic ) + s;
       p := Length( s );
     end;
   isx := StrToInt( s );
   if isx >= modu
     then ic := isx mod modu
     else ic := isx;
  result := ic;
end;