Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binary items and Nulls

Status
Not open for further replies.

dickiebird

Programmer
Feb 14, 2002
758
GB
for FILENAME in `ls /data/orox/lrlamn05*`
do
FILEN=`basename $FILENAME`
awk -v gD="$d" -v gM="$m" -v gY="$y" -vINFILE="$FILEN" '
function cvt_6_byte_to_num(value)
{
num=0
powerf=5
for (loop=0; loop != 6; loop++)
{
num += (value[loop] * to_power_of(2, 8 * (powerf--)))
}
return (num)
}
function to_power_of(val,power)
{
numb = 1
for (c=0; c < power; c++)
{
numb = numb * val
}
return(numb)
}

BEGIN {
close(OFILE)
OFILE=&quot;EXT&quot; INFILE
rate=0
printf(&quot;HDR Exch.Rate for %d/%d/%d %&quot;,gD,gM,gY,OFILE) > OFILE
sprintf(value,&quot;%06s&quot;,substr($0,1,6))
rate=cvt_6_byte_to_num(value)
printf(&quot;Rate1=%d\n&quot;,rate) >> OFILE

}' ${FILEN}
done

Its the contents of field 'value' that I want to pass to the
conversion function - but seems to have nothing in it
Thanks in advance to anyone with an idea for a fix
Regards
DickieBird
 
Change the sprinf to
[tt]
value = sprintf(&quot;%06s&quot;,substr($0,1,6))
[/tt]
Hope this helps. CaKiwi
 
Sorry CaKiwi - still no joy !
I may have to write a C prog to do it
Thanks anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top