FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Is this the correct way to create a one byte LRC
Posts: 67
Joined: Thu Jan 05, 2006 10:35 PM
Is this the correct way to create a one byte LRC
Posted: Wed Nov 18, 2009 08:14 PM
Thanks In Advance -
Is this the correct way to create a one byte LRC
Code (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Is this the correct way to create a one byte LRC
Posted: Wed Nov 18, 2009 09:24 PM
Mike,

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

the right code would be:
Code (fw): Select all Collapse
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
Posts: 67
Joined: Thu Jan 05, 2006 10:35 PM
Re: Is this the correct way to create a one byte LRC
Posted: Thu Nov 19, 2009 05:16 PM

Thanks Mike

Continue the discussion