home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
13
/
N_B_V203.ZIP
/
ISBN.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
5KB
|
89 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME ISBN .DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
$endif
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
$INCLUDE "DAS-NB01.INC"
COLOR 7,0
CLS
? "┌─────────────────────────────────────────────────────────────────────────────
? "│ ISBNmask ( NewMask$ )
? "│ fISBN% ( ISBN$ )
? "│ fISBNck% ( ISBN$ )
? "├─────────────────────────────────────────────────────────────────────────────
? "│ ISBNmask works with fISBN% and provides it with your preferred display style.
? "│ If you are going to re-format all ISBNs then you need to call it first then
? "│ use fISBN% to both check and reformat ISBN$.
? "│ fISBNck% only checks ISBN$ for correctness and does not re-format the STR.
? "├─────────────────────────────────────────────────────────────────────────────
? "│ Intl Sadistic Book Numbers consist of: The dashes separate:
? "│ 9 numbers 1 the country
? "│ 3 dashes 2 the publisher
? "│ 1 check digit: 0123456789X 3 the publisher's book N°
? "│ 4 the check digit
? "│ The problem comes in the fact that the country number, publisher number,
? "│ and book number can be of any length! Only the check-digit is a constant of
? "│ 1 digit (or an X). To be 100% correct you cannot reformat the ISBNs & should
? "│ require your users to input the dashes but, as I found out, most users (even
? "│ the pros) prefer the ISBNs to be formatted the same and forget the rest.
? "└─────────────────────────────────────────────────────────────────────────────
ISBNmask "##-##-#####-#" '│ set the format mask
Good$ = "0174433042" '│ this is a good ISBN
Bad$ = "0174333042" '│ this one has a typo error
'│
Ok% = fISBN%( Good$ ) '│ GOOD ONE
PRINT Good$; '│
IF NOT Ok% THEN PRINT " NOT"; '│
PRINT " OK" '│
'│
Ok% = fISBN%( Bad$ ) '│ BAD ONE
PRINT Bad$; '│ note that the string has NOT been
IF NOT Ok% THEN PRINT " NOT"; '│ reformatted as it is incorrect
PRINT " OK" '│
'│
$if 0
A further note here:
In all fairness, ISBNs have been around longer than computers so they were
created a bit illogically. There, also, wasn't much room for expansion of
countries and publishers. As a point of interest 01 is England and 7 is/was
Nelson Publishing and my clients preferred 017-44-3304-2 which is totally out
of sync with all the rules but most of today's products are in the 440,000
range and they tended to work with only the "3304". The program doesn't care
what style the number is in as it ignored everything except the numbers and
if the check digit "2" was correct then it was happy. As only the people in
the Nelson office used/uses the program & print-outs it was more efficient to
put the ISBNs in a format that the humans used than to enforce an unnecessary
rule.
The purpose of this discussion is more important than the discussion itself.
1) don't impose unnecessary "rules" on your users as the computer
usually doesn't care one way or the other
2) most account numbers today have a check digit
This includes Banks, credit cards, stock numbers, etc. so when
you have to work with them find out the algorithm being used
and incorporate it into your program then check all incoming
data. This saves hours and hours of human down-time looking for
some obscure error!
$endif