dickiebird
Programmer
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="EXT" INFILE
rate=0
printf("HDR Exch.Rate for %d/%d/%d %",gD,gM,gY,OFILE) > OFILE
sprintf(value,"%06s",substr($0,1,6))
rate=cvt_6_byte_to_num(value)
printf("Rate1=%d\n",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
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="EXT" INFILE
rate=0
printf("HDR Exch.Rate for %d/%d/%d %",gD,gM,gY,OFILE) > OFILE
sprintf(value,"%06s",substr($0,1,6))
rate=cvt_6_byte_to_num(value)
printf("Rate1=%d\n",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