Is this the correct way to create a one byte LRC

Is this the correct way to create a one byte LRC

Postby Mike Buckler » Wed Nov 18, 2009 8:14 pm

Thanks In Advance -
Is this the correct way to create a one byte LRC
Code: Select all  Expand view
function MyLRC(text)
local ret:=left(text,1),x
    for x = 2 to len(text)
       ret:=chr(nXor( asc(ret), Asc(substr(text,x,1) )   ) )
    next
   return ret
Mike Buckler
 
Posts: 67
Joined: Thu Jan 05, 2006 10:35 pm
Location: Canada

Re: Is this the correct way to create a one byte LRC

Postby Antonio Linares » Wed Nov 18, 2009 9:24 pm

Mike,

According to this C code:
http://www.as400pro.com/tipView.php?cat=C&key=8

the right code would be:
Code: Select all  Expand view
function LRC( cText )

   local nCheckSum := 0
   local n

   for n = 1 to Len( cText )
      nCheckSum = nXor( nCheckSum, Asc( SubStr( cText, n, 1 ) ) )
   next

return nCheckSum
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Is this the correct way to create a one byte LRC

Postby Mike Buckler » Thu Nov 19, 2009 5:16 pm

Thanks Mike
Mike Buckler
 
Posts: 67
Joined: Thu Jan 05, 2006 10:35 pm
Location: Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 86 guests