Solved

Calculate an ISBN checksum?

Posted on 1998-12-16
3
1,099 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

728 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