Hi everyone,
I dint not post the complete program, just the most relevant parts. I think the problem is with conversion part towards the end . I cant print the correct values to the text or edit box on the GUI, it prints out some weird values. Thanks in advance for the help. The value "ADD" is like "5.641087567e-007".
int i, chemsel =0, idx=1, n = 0;
AnsiString str, chemicalname;
FILE * SourceFile, *SourceFile1;
char *token, *token1, sizeLineInput1[1000], sizeLineInput[10000], c, num[15];
float test2, array[10000], largest = array[1];
long double ChemRfDwater, HazardQuotient, ADD;
Edit8->Text = "";
chemicalname = (Edit3->Text);
if (chemicalname == "7440-38-2")
{
ChemRfDwater = 0.0003;
this->Edit8->Text = FloatToStr(ChemRfDwater);
}
else if (chemicalname == "7440-43-9")
{
ChemRfDwater = 0.0005;
this->Edit8->Text = FloatToStr(ChemRfDwater);
}
else if (chemicalname == "7440-02-0")
{
ChemRfDwater = 0.02;
this->Edit8->Text = FloatToStr(ChemRfDwater);
}
else if (chemicalname == "7783-79-1")
{
ChemRfDwater = 0.005;
this->Edit8->Text = FloatToStr(ChemRfDwater);
}
else if (chemicalname == "7440-66-6")
{
ChemRfDwater = 0.3;
this->Edit8->Text = FloatToStr(ChemRfDwater);
}
FILE *SourceFile = fopen ("c:\\temp\\test.grf","r");
if (SourceFile != NULL)
{
while(fgets(sizeLineInput, 10000, SourceFile)!=NULL)
{
token = strstr(sizeLineInput ,"IngWater_HumRcp");
if (token)
{
fgets(sizeLineInput, 10000, SourceFile);
while((c=fgetc(SourceFile))!='\r')
{
if(c==',')
{
num[idx]=0;
n++;
array[n] = atof(num);
idx=0;
}
else
{
num[idx] = c;
idx++;
}
break;
}
}
}
for (int i=1;i<n+1;i++)
{
if (array[i]>largest)
{
largest=array[i];
}
}
ADD = largest;
HazardQuotient = (ADD/ChemRfDwater); // Here is the problem
this->Edit9->Text = FloatToStr( HazardQuotient); //Here is the problem
if (token == NULL)
{
Application->MessageBox("Refer to the messages for details.\n It could be one of the several reasons, namely:\n 1. Mass does not reach water-table. \n 2. Mass does not reach well. \n 3. Well is not in the direction of the aquifer.", "Message", MB_OK + MB_DEFBUTTON1);
}
}