Page 32 of 59
Appendix C – TAP Checksum Calculation
Following is a sample Visual Basic™ code, that creates a string to be sent to the paging encoder. A subset of the
string has a checksum calculation performed on it, and then the checksum and a control character are appended
to form the string to be sent to the paging system. Refer to the TAP specification for more details on the
checksum calculation.
'String that checksum is calculated on, of the form:
‘<STX>ID<CR>Message<CR><ETX>
TXString$ = Chr(2) & txtID.Text & Chr(13) & txtMessage.Text & Chr(13) & Chr(3)
'Calculate and append checksum
j = 1
Sum = 0
Do Until j > Len(TXString$)
B$ = Mid(TXString$, j, 1)
D = Asc(B$)
Sum = Sum + D
j = j + 1
Loop
'Create the three characters to be transmitted to represent this checksum.
d3 = 48 + Sum - Int(Sum / 16) * 16
Sum = Int(Sum / 16)
d2 = 48 + Sum - Int(Sum / 16) * 16
Sum = Int(Sum / 16)
d1 = 48 + Sum - Int(Sum / 16) * 16
Check1$ = Chr$(d1)
Check2$ = Chr$(d2)
Check3$ = Chr$(d3)
CheckSum$ = Check1$ & Check2$ & Check3$
'Create complete string to be sent to paging system, of the form:
‘<STX>ID<CR>Message<CR><ETX>Checksum<CR>
TXString$ = TXString$ & CheckSum$ & Chr(13)
This Completes the “Tap Checksum Calculations”