I have a program that open a file (the user input the name of the file … as been solicited).
I need the file to make various types of analysis … anyone of them are functions.
Well, there is a way to record the name of the file in a variable that could be used after by any function ?
I strongly recommend that you try to find a C++ specialist that you can meet in person to discuss the issues you currently have. You latest questions are very general (i.e. they do not seem require any knowledge of ROOT to investigate). In addition you are not specific enough in your question for us to be able to decipher what might be going wrong. (My previous answer to your general question still stand … and I have not the beginning of a clue on how/why it failed for you).
I could try to explain …
I open a file with TFile Object but my problem is that I want to save the name of the file in a variable that could be used after…
I have something like this …
void main()
{
char iname;
cout << “input the name of the file to analyze …” << endl;
cin >> iname;
F1();
F2();
…
and so on … (it depends on the type of analysis required)
}
void F1()
{
cout << iname << endl;
TFile *file1=new TFile(iname, …);
…
}
that’s something like this that I want …
the user input the name of the file
them the program analyse it … accordlly with the the type of analysis selected … avaiible in a menu
Well it’s a mistake … beacuse what I want to write is char *iname …
I try your suggestion but inside the ROOT it seems that doens’t work …
I only want to know a way to record into a variable the name of one file … intruduced by the user (only one time) … and after that I pass the value of this variable into the functions that I was builded …
Yes !?? How does it fail? What did you try? It is hard to help you out when your issue stay so vague.
As I send a global variable would solve your problem (or maybe a function static).
I still think you would benefit from seating down with a C++/programming expert and discuss this issue face to face.
but when I try it in ROOT everything works bad …
Except for forgetting to create a dictionary for some symbol, there are no reason why something which in C++, would not work when also using ROOT. You do not provide enough information to have any clue on what your problem is.
JP, you should compile your programs instead to trying to make ROOT
macros out of them. I never use macros because if you comile a program you
can use all the power and flexebility of C++, use any external
librairies… just do anything including linking ROOT libraries and using
anything from ROOT If you stick only to macros you often become limited
in what you can do
If all your program is one file MyAnalysis.C this is a simple make file showing how
to compile it with ROOT libraries: