Solved

Calculate an ISBN checksum?

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Downloading email attachments 2 84
Delphi 2 77
Microsoft Access 97 and Delphi XE2 9 72
Delphi Firmonkey, Android:  blocking dialogs not implemented on this platform 5 57
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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 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