evaluate_cell().
By SalimMeghani
- 205 reads
// Evaluate and store contents of a cell in szBuffer.
void evaluate_cell(int column, int row, char type, char *szBuffer, char top, char *genetic)
{
errflag=0;
switch(type)
{
case 'S':
{
int pvalue=0;
pvalue=((column-1)*100)+row;
cell=scell+pvalue;
sprintf(szBuffer, "%9s", *cell);
break;
}
case 'N':
{
int pvalue=0;
pvalue=((column-1)*100)+row;
numeric=snumeric+pvalue;
if (*(*numeric)==-0) *(*numeric)=0;
if ((*(*numeric)>99999.99) || (*(*numeric)<-99999.99)) sprintf(szBuffer,"%s"," Overflow");
else
sprintf(szBuffer, "%9.2f",*(*numeric));
break;
}
case 'F':
{
int pvalue=0;
pvalue=((column-1)*100)+row;
cell=scell+pvalue;
value=expr_p(&errflag, *cell,column,row);
if ((!errflag) && (top=='D') && ((value>99999.99)||(value<-99999.99)))
sprintf(szBuffer,"%s"," Overflow");
else if ((!errflag)&&(top=='D'))
sprintf(szBuffer, "%9.2f",value);
else if (!errflag)
sprintf(szBuffer,"%e",value);
else
{
sprintf(szBuffer, "%s"," Error ");
}
break;
}
default:
sprintf(szBuffer," ");
break;
}
}
- Log in to post comments