macro problem

From: Dr. Roberto Barbera (roberto.barbera@CT.INFN.IT)
Date: Thu Dec 03 1998 - 11:02:06 MET


Hi experts,

I've modified the tutorial macro basic.C to read an ASCII file
containing several lines of 12 elements each (3 integers and 9 reals).
Here is the macro i'm using:


{
//
// A short macro to read the Detector Map file and store the data on
some
// useful vectors
//
//

	gROOT->Reset();
        gBenchmark->Start("readet");
	
	Int_t ilayer,iladder,idet;
	Int_t ncols;
        Int_t nlines = 0;

 	Float_t f1,f2,f3,f4,f5,f6,f7,f8,f9;
	
	FILE *detfile = fopen("file.dat","r");

        if (detfile <= 0) printf("Error: file could not be open\n");
  
        printf("Reading Detector Map from file...\n");

        while (1) {
            ncols = fscanf(detfile,"%i %i %i %f %f %f %f %f %f %f %f
%f",
            &ilayer,&iladder,&idet,&f1,&f2,&f3,&f4,&f5,&f6,&f7,&f8,&f9);
            if (ncols < 0) break;
	    if (nlines < 5) {
		printf("%i %i %i %f %f %f %f %f %f %f %f %f \n",
		ilayer,iladder,idet,f1,f2,f3,f4,f5,f6,f7,f8,f9);
            }	    
	    nlines++;
        }
	printf(" %i lines found \n",nlines);
        fclose(detfile);	
	gBenchmark->Show("readet");
        gROOT->Reset();
}


and this is what i get when i run the macro inside ROOT:

root [0] .x readet.C
Reading Detector Map from file...
Limitation: fscanf only takes upto 12 arguments
FILE:/pcct54_hdb1/barbera/galice
/v2.06pre/./readet.C LINE:34
 0 lines found
readet    : Real Time =   0.02 seconds Cpu Time =   0.02 seconds
root [1]

It seems that no lines are read but they indeed ARE in the file. Any
help will be greatly appreciated.


						ciao

						Roberto

-- 
Dr. Roberto Barbera (mailto:roberto.barbera@ct.infn.it)
Phone: ++.39.095.71.95.232 
Fax: ++.39.095.38.30.23
WWW: http://www.ct.infn.it/~barbera



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:40 MET