I actually screwed up the way I worked with my files.
The rest of the def's was fine.
here's the whole function:
Code:
int MakeWord(FILE *out, DataLine *Line, float value, int word)
{
int number;
word =0;
/*fprintf(out, ">%s %d %d %d %d %d %d %d\n<", Line->Param, Line->Label,
Line->SFactor, Line->SigBits, Line->Bit30,
Line->Bit31, Line->Max, Line->Min);*/
// check if the value is valid
if(value == -9999)
return 0;
//Input the label
word = MakeLabel(Line->Label);
fprintf(out, " label %08x \n", word);
//Check if value is negative
if(value < 0)
{
word = word | 0x10000000; // Set the sign bit to 1
value = -value ;
}
// Set bits 30
if (Line->Bit30 == 1)
word = word | 0x20000000;
else
{
word = word << 3;
word = word >> 3;
}
//and bit 31
if (Line->Bit31 ==1)
word = word | 0x40000000;
else
{
word = word << 2;
word = word >> 2;
}
fprintf(out, " bits 30/31 %08x \n", word);
// Data part
if (Line->SFactor>0)
{
value = value*(float)pow(2,31)/Line->SFactor;
//printf("Value: %08x\n\n", value);
number = ((int)value)>>3;
//printf("Number: %08x\n\n", number);
}
word = word | (number & DATAMASK18);
fprintf(out, " data %08x \n", word);
// Set parity to 0
word = word << 1;
word = word >> 1;
fprintf(out, " parity %08x \n", word);
return 1;
}
and it's called like this:
Code:
MakeWord(out, &FAD.vectDL[i],
Value, TempWord);
when I try to print TempWord after the function call it's empty, but inside the function word is adjusted and the last fprintf states the correct result. Why doesn't it reflect the correct value for TempWord?