Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a checksum for a record
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00344258
Message ID:
00344855
Views:
23
Here's one kind of CheckSum, maybe it help some:
* Check Sum error. Using the last digit of checknum as position 0
* and counting left:
* Sum the even digits (including pos 0) to Check sum
* For odd numbered digits:
* double them
* if the doubled is 10 or higher
* sum the value of each digit to check sum
* else
* just add the value to checksum
* If chek sum divided by 10 returns an integer, it passed!
c=len(CheckNumb)+1
cheksum=0
do while c>0
c=c-1
cheksum=cheksum+val(substr(CheckNumb,c,1))
chekval=str(val(substr(CheckNumb,c-1,1))*2,2)
if len(trim(chekval))>1
chekval=val(left(chekval,1))+val(right(chekval,1))
else
chekval=val(chekval)
Endif
cheksum=cheksum+chekval
c=c-1
enddo
CheckNumberError=iif(right(str(cheksum,3),1)=[0],.f.,.t.)


>Greetings all,
>
>A Question: I'm needing to create a checksum value for a record in a table based on the data in each field. Does anyone have an algorithm to share or know of a third-party utility to do same?
>
>TIA
Imagination is more important than knowledge
Previous
Reply
Map
View

Click here to load this message in the networking platform