[futurebasic] Re: [FB] Hex???

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2004 : Group Archive : Group : All Groups

From: Jay Reeve <jayreeve@...>
Date: Mon, 15 Mar 2004 08:37:38 -0600
On Monday, March 15, 2004, at 05:31  AM, John Clark wrote:

> Hello Out there,
>
> I'm kludging together some GPS NMEA 0183 thing. The manuel says"
>
>         The optional checksum field consists of a "*" and two hex 
> digits
>         representing the exclusive OR of all characters between, but 
> not
>         including, the "$" and "*".  A checksum is required on some
>         sentences.
>
> Hex digits. I must have left the room then...
>
> My old checksum routine goes...
>
> Clear Local
> LOCAL FN CalcSum$ (Out$)                      'Calculate the Xor-ed 
> checksum
>   checksum = 0
>   FOR n = 1 TO LEN(Out$)
>     checksum = checksum XOR ASC(MID$(Out$, n, 1))
>   NEXT
> checksum$ = FN Stripper$(str$(checksum$))
> END FN = checksum$
>
> How do I convert the numbers to hex??

Try this:

defstr byte
Clear Local
LOCAL FN CalcSum$ (Out$)                      'Calculate the Xor-ed 
checksum
dim checksum,n
   FOR n = 1 TO LEN(Out$)
     checksum = checksum XOR Out$[n]
   NEXT
out$ = HEX$(checksum)
END FN = out$

  e-e
  =J= a  y
   "