Difference between revisions of "ISO 7064"
From Free Pascal wiki
Jump to navigationJump to searchm (Fixed syntax highlighting) |
|||
Line 5: | Line 5: | ||
== Function StrMOD97 == | == Function StrMOD97 == | ||
− | The function StrMOD97 can encode and verify number checksum with ISO 7064 | + | The function StrMOD97 can encode and verify number checksum with ISO 7064. |
<syntaxhighlight lang=pascal> | <syntaxhighlight lang=pascal> | ||
− | + | function StrMOD97(s: String): integer; | |
− | function StrMOD97( s :String):integer; | ||
const | const | ||
modu = 97; | modu = 97; | ||
var | var | ||
− | sx :String; | + | sx: String; |
− | isx,ic,p:Integer; | + | isx, ic, p: Integer; |
begin | begin | ||
p := Length( s ); | p := Length( s ); | ||
− | while( p > 9 ) do | + | while ( p > 9 ) do |
begin | begin | ||
sx := Copy( s, 1, 9 ); | sx := Copy( s, 1, 9 ); | ||
Line 32: | Line 31: | ||
result := ic; | result := ic; | ||
end; | end; | ||
− | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 20:29, 28 November 2021
│
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.
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;