Vc++ directroy

hi,
I use root_v5.15.02.win32gdk and vc++2005
i read *.dat file and save the full pathname(FileName=pDlg.GetPathName())
but when i make a TFile, it dosen’t made at current directory
root file is made at *.dat file’s directory.
how can i solve it.

Could you posts a short script showing what you are attempting to do?

Rene

I,m so sorry because my poor english. I can’t explain perfectly but I try.
I made 3 funtion for make root file. but when i select *.dat file
It it’s very annoying work because I must change the path every time by typing. so, I made button that using vc++ funtion, and save fullpath to some variable like this(FileName = pDlg.GetPathName())
Upon that *.root file didn’t make at current directory. befor *.root file is made current directory. but after using button it didn’t make rootfile at current directory rootfile is created at FileName’s directory.

void CROOTmakeView::OnBnClickedButtonReadfile()
{
CClientDC dc(this);
CString str;

int a = 0;
int b = 0;
int c = 0;
int d = 0;
int nlines = 0;

LPCTSTR fn = "c:\\root\\macros\\bae.dat";	
CFile file;
CFileException fe;
DWORDLONG dwBitsSize;

stor_packet_hdr_t ph;
const int bsz = 4096;
init_trees();
UChar_t buf[bsz];
file.Open(fn,CFile::modeRead,&fe);
            dwBitsSize = file.GetLength();
str.Format("파일크기 = %d",dwBitsSize);
dc.TextOutA(10,570,str);

while(dwBitsSize>0)
{
               .....
               .....
               .....
	
}
finish_trees();
file.Close();	

}
void CROOTmakeView::init_trees(void)
{
CClientDC dc(this);
CString str;

            //////here is my current directory./////////////

const char *rfn ="c:\\ROOTmake\\ROOTmake\\bae.root";
rf = new TFile(rfn,"RECREATE");
if(!rf)
{
	str.Format("Can't create file");
	dc.TextOutA(500,50,str);
	exit(1);
}
rt = new TTree("tree","events");
if(!rt) 
{
	str.Format("Can,t create Tree.");
	dc.TextOutA(500,70,str);
	exit(1);
}
            rt->Branch("dt", &r_dt, "dt/F");
rt->Branch("qa", &r_qa, "qa/F");
rt->Branch("qg", &r_qg, "qg/F");
rt->Branch("wa", &r_wa, "wa/F");
rt->Branch("wg", &r_wg, "wg/F");
rt->Branch("ca", &r_ca, "ca/s");
rt->Branch("cg", &r_cg, "cg/s");	

}

void CROOTmakeView::finish_trees(void)
{
rt->Write();
rf->Close();
}

void CROOTmakeView::handle_block(const stor_packet_hdr_t &ph, const unsigned char *buf)
{
CClientDC dc(this);
CString str;

if(ph.id == STOR_ID_CMAP) {
}
else if(ph.id == STOR_ID_EVNT)
{
..........
            ...........
            ...........
	if(ng>0)
	{
		r_qg = hg[0]->a;
		r_wg = hg[0]->w;
		r_cg = hg[0]->ch - g_ch_start;
	}
	else
	{
		r_qg = 0; r_wg = 0; r_cg = 0;
	}
	n_good++;
	rt->Fill();		
}
else if(ph.id == STOR_ID_CNTR) {
}

}
I can make a root file and histogram but i can’t handle a directory.
void CROOTmakeView::OnBnClickedButtonOpen()
{
CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CEdit pEdit = (CEdit)pFrame-GetDlgItemIDC_EDIT_PATH);
UpdateData(TRUE);
//CEdit *pEdit = (CEdit)pFrame->m_wndEditBox.GetDlgItem(IDC_EDIT_PATH);

char Filter[] = "dat File(*.dat)|*.dat|allfile(*.*)|*.*|";
CFileDialog pDlg(TRUE,"dat file(*.dat)","*.dat",OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, Filter, NULL);
if(pDlg.DoModal()==IDOK)
{
                ------------->FileName = pDlg.GetPathName();        
	pEdit->SetWindowTextA(FileName);
	UpdateData(FALSE);
}		

}

Hello,

I’m really sorry, but I don’t really understand what you are trying to do…
Maybe gSystem->ChangeDirectory(“your desired path”); or _chdir(“your desired path”); may help ?

Bertrand.

thank your reply i solved that problem.
but I have many question. i need a advise.
how can i get the b value use a A point.

Hi,

Int_t bin = hqg->GetXaxis()->FindBin(A);
B = hqg->GetBinContent(bin);

HTH, Bertrand.

I was fallowing your advise.
Int_t bin = hqg->GetYaxis()->FindBin(4.44);
bin value is 67
Int_t bin = hqg->GetBinContent(4.44);
bin value is 165
but I want a 4000(y point)value.
what’t a problem, scale?

PLEASE, PLEASE, Make an effort to understand what you are typing !!
What Bertrand told you should have been obvious.

Int_t bin = hqg->GetXaxis()->FindBin(4.44); // not Yaxis double yvalue = hqg->GetBinContent(bin);
Rene

Thank for your help, Now I solved many problem. Anyway,I decide to study english more.