Reading from a Text file and Double Numbers

 

Hi All

I am using the following piece of code to read data from a text file

sample data :

1.2345,1.4321,1.6545

1.7654,1.4432.1.6535

1.6556,1.5642,1.3645

The problem I have is that the code will not read any thing after the point so all it is returning is 1 for every piece of data.

Does anyone know how I can work around this?

ANy help would be most appreciated

Cheers

scouseman


int start()
{
int counted_bars=IndicatorCounted();
//----
int val[3][9],i,j,handle;
handle=FileOpen("test.csv",FILE_READ|FILE_CSV,',') ; // last parameter is a space, as it appears your delimiter is a space
if(handle==-1)return(0);// if not exist
if(FileSize(handle)==0){FileClose(handle); return(0); } //if empty
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
val[i][j]=StrToInteger(FileReadString(handle));//read one variable
Print("Val",i," s ",j," - ",val[i][j]);//You can print it to be sure

FileClose(handle); //close file

return(0);

}

 

int can't Contain a decimal number

 

Hi qjol

I realised that after I had posted my message, I tried by changing:

val[i][j]=StrToInteger(FileReadString(handle)); to val[i][j]=StrToDouble(FileReadString(handle));

which I thought would fix it but it has'nt..

I will just have to keep trying to work out, unless somebody come to my rescue.

Cheers

scouseman

 

Sorted it now :)

Just changed

int val[3][9],i,j,handle;

to

double val[3][9];

int i,j,handle;


There we have it sorted


Cheers

scouseman