forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


EAN to ISBN convertor

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code
View previous topic :: View next topic  
Author Message
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Sun Aug 29, 2004 3:17 pm    Post subject: EAN to ISBN convertor Reply with quote

Hi guys,
I had to write this script for a library management program (written in VDS of course Wink). Perhaps it's useful to any of you... you never know.

It converts the EAN number stored in the barcode at the back of a book to a valid ISBN number. Could be useful if you want to allow your users to scan that barcode to add the book to a database, for example Smile

Code:

# This variable must hold the number which is stored in the barcode
%%Import = 9780747551003

%%ISBN = @trim(@substr(%%Import, 4, @pred(@len(%%Import))))
   
%%ISBN_ProdSum = @sum(@prod(@substr(%%ISBN, 1, 1), 10), @prod(@substr(%%ISBN, 2, 2), 9), @prod(@substr(%%ISBN, 3, 3), Cool, @prod(@substr(%%ISBN, 4, 4), 7), @prod(@substr(%%ISBN, 5, 5), 6), @prod(@substr(%%ISBN, 6, 6), 5), @prod(@substr(%%ISBN, 7, 7), 4), @prod(@substr(%%ISBN, 8, Cool, 3), @prod(@substr(%%ISBN, 9, 9), 2))
 
%i = 0
repeat
    %i = @succ(%i)
until @both(@not(@greater(@prod(%i, 11), %%ISBN_ProdSum)), @greater(@prod(@succ(%i), 11), %%ISBN_ProdSum))
 
%%ISBN_CheckDigit = @diff(11, @diff(%%ISBN_ProdSum, @prod(%i, 11)))
if @equal(%%ISBN_CheckDigit, 11)
    %%ISBN_CheckDigit = X
elsif @equal(%%ISBN_CheckDigit, 10)
    %%ISBN_CheckDigit = 0
end
 
%%ISBN = %%ISBN%%ISBN_CheckDigit

info The ISBN number is %%ISBN


Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Aug 29, 2004 3:38 pm    Post subject: Reply with quote

Interesting. Nice work. Wink
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Sun Aug 29, 2004 3:39 pm    Post subject: Reply with quote

Nice work indeed!
Back to top
View user's profile Send private message
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Sun Aug 29, 2004 3:39 pm    Post subject: Reply with quote

Thanks Wink I had no idea if anybody would ever use this though, but I thought it was better to share the code just in case Very Happy

Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group