Solved

Calculate an ISBN checksum?

Posted on 1998-12-16
3
1,095 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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