Root do not read data

[size=125]I use Root 5.17.02 installed on Windows xp. I launch automatically ROOT starting from microsolft visual BASIC 6.0 using following script:[/size]

[quote]Private Sub Form_Load()
Shell "C:\root\bin\root.exe C:\root\test.C"
End Sub[/quote]

the program that I try to carry out in ROOT is as follows:

[quote]#include “TH1F.h”
#include “TCanvas.h”
#include “Riostream.h”

void test()
{
gROOT->Reset();
ifstream in;
in.open(“data.dat”);

Float_t x;
Int_t nlines = 0;
// TFile *f = new TFile(“data.root”,“RECREATE”);

TH1F*h1 = new TH1F(“h1”, “X distribution”,100, 0,100);
while (1) {
in >> x ;
if (!in.good()) break;
h1->Fill(x);
nlines++;
}

printf(" found %d points",nlines);
in.close();
// f->Write();

TCanvas *C1 = new TCanvas(“1X”, “1X”,1);
h1->Draw();
}[/quote]

[size=125]The program carried out, the “canvas” appeared, the axes are drawn
but the histogram does not appear. and the program write
0 points found (enty 0). What means that it does not manage to open the file containing data to read them.

On the other hand when I launch my program directly in ROOT using .x test.C it is carried out normally data are read without problem.

I have carry out tests with other programs and the behavior is the same one. each time that there is data to read they are not read.

On the other hand when there is not data to read the program is carried out without problem. This problem poisons my life since more than one week and I do not manage to find an explanation. What does it occur? what can I make to cure it?
Thank you in advance for your answer

[/size]

Hi,

I assume that the problem is that the current file system directory is not the one you expect and that in.open("data.dat"); fails because it can not find the file data.dat. So you should first assert that the file is where you expect it and that the current file system directory is the one you expect.

Also do no use gROOT->Reset() inside a function.

Cheers,
Philippe

Thank you for this sacrifice of Sunday,
I did not expect an answer before Monday
If the current file system directory is not the one I expect,
How to explain that by using .x test.C the program walks without problem?
Moreover the constructor ifstream file("filename",ios::in|ios::binary); does not offer the possibility of specifying where is the file to open.

What do you mean by:

[quote]If the current file system directory is not the one I expect,
[/quote]
and

[quote]Moreover the constructor
Code:
ifstream file(“filename”,ios::in|ios::binary);
does not offer the possibility of specifying where is the file to open.[/quote]
Instead of “filename” you can specify a partial or full path, but this looks so basic that I am probably missing something in your question.

Rene

pcanal and Rene
I regret the nuisance which I caused to you, the answer of Rene led me to look at my path again and I realized that in root I had put \ at the place of /. A stupidity which lost me one week. Once more Thank you for your assistance!