ISBN13 check digit: Difference between revisions

Content added Content deleted
Line 1,279: Line 1,279:
=={{header|EasyLang}}==
=={{header|EasyLang}}==
<syntaxhighlight lang="text">
<syntaxhighlight lang="text">
proc ISBN13check ISBN$ . valid .
func ISBN13check isbn$ .
for i = 1 to len ISBN$
for c$ in strchars isbn$
currentChar$ = substr ISBN$ i 1
if c$ <> "-"
if currentChar$ <> "-"
ndigs += 1
digitCounter += 1
.
.
currentDigit = number currentChar$
dig = number c$
if digitCounter mod 2 = 0
if ndigs mod 2 = 0
currentDigit *= 3
dig *= 3
.
.
sum += currentDigit
sum += dig
.
.
if sum mod 10 = 0
if sum mod 10 <> 0
valid = 1
return 0
else
valid = 0
.
.
return 1
.
.
ISBNcodes$[] = [ "978-0596528126" "978-0596528120" "978-1788399081" "978-1788399083" ]
codes$[] = [ "978-0596528126" "978-0596528120" "978-1788399081" "978-1788399083" ]
for ISBN$ in ISBNcodes$[]
for code$ in codes$[]
call ISBN13check ISBN$ valid
if ISBN13check code$ = 1
print code$ & " is a valid ISBN"
if valid = 1
print ISBN$ & " is a valid ISBN"
else
else
print ISBN$ & " is not a valid ISBN"
print code$ & " is not a valid ISBN"
.
.
.
.