Subject: Re: Longitudinal Redundancy Check! - DN [1]


Roger E Critchlow Jr <rec@elf.org> - 20 Sep 1999 - comp.lang.tcl

 Michael Newton <mnewton@omegafilters.com> writes:

 > I need a Tcl routine to calculate a Longitudinal Redundancy Check
 > character for a string. An LRC is calculated by XORing each byte in the
 > string. I found some C that does it, but I am not knowledgeable enough
 > to achieve it in Tcl.
 >
 > Here's C that does what I need:
 >
 > unsigned char func_makelrc(char *buff)
 > {
 >    int i;
 >    char ch, *p;
 >
 >    ch = 0;
 >    p = buff;
 >
 >    for(;;)  {
 >       ch = (ch^(*p));
 >       p++;
 >       if(!(*p))
 >          break;
 >    }
 >
 >    return ch;
 > }
 >
 > Could someone please lend a hand doing this in Tcl?

 proc func_makelrc {string} {
   binary scan $string c* string
   expr [join $string ^]
 }

 -- rec --

Last modified
1999-09-28

(195.108.246.51)

Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated