Solved

Calculate an ISBN checksum?

Posted on 1998-12-16
3
1,075 Views
Last Modified: 2008-03-10
Hello Everyone,

I am trying to automate a few things here at the office for everyone. One of my projects is to create a simple program (very simple) that calculates the checksum or check digit of an ISBN number.

For example:
If you had an ISBN number of 157521030, the checksum would be 4. I've seen examples to verify the checksum, and I've seen the mathmatical equation, but I was wondering if anyone had a simple function or routine that does this? Perhaps a pointer to one that does?

Any help or guidance would be greatly appreciated.

Sincerely,

Sandra Wallace
sandra_wallace@yahoo.com

0
Comment
Question by:sandra_wallace
  • 2
3 Comments
 

Author Comment

by:sandra_wallace
ID: 1351401
Edited text of question
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 1351402
This function will calculate the ISBN checksum:

function ISBNCheckDigit(ISBN :string):char;
var
  CheckSum : integer;
  ModValue : Integer;

begin
  CheckSum := 10 * strtoint(ISBN[1]);
  CheckSum := checksum + 9 * strtoint(ISBN[3]);
  CheckSum := checksum + 8 * strtoint(ISBN[4]);
  CheckSum := checksum + 7 * strtoint(ISBN[6]);
  CheckSum := checksum + 6 * strtoint(ISBN[7]);
  CheckSum := checksum + 5 * strtoint(ISBN[8]);
  CheckSum := checksum + 4 * strtoint(ISBN[9]);
  CheckSum := checksum + 3 * strtoint(ISBN[10]);
  CheckSum := checksum + 2 * strtoint(ISBN[11]);
 
  ModValue := Checksum mod 11;
  if ModValue < 10 then
    result := chr(asc('0') + ModValue - 1)
  else
    result := 'X';
end;

Cheers,

Raymond.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1351403
Oops,  this line

 result := chr(asc('0') + ModValue - 1)

should read

 result := chr(ord('0') + ModValue - 1)

Cheers,

Raymond.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
delphi prevent click fast 2 166
code issue 8 85
find a node in VST 2 47
oracle global variables 4 52
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now