Re: defining action on the TControlBar

Rene Brun (Rene.Brun@cern.ch)
Thu, 04 Sep 1997 16:13:30 +0200


Luca Sfarzo wrote:
>
> Hello,
>
> I am using Root' TControlBar to make an interface.
> I am writing a stand alone prog.
> All seem to work when but when the program ties to run the function
> attached to the button I press I get a strange behaviour.
>
> part of the code is:
>
> ....
> 1) TControlBar *MainBar = new TControlBar("vertical");
>
> 2) MainBar->AddButton("Content of the dir","shoContent(*nameFile, f)",
> "Show content");
>
> 3) MainBar->AddButton("Change directory", "changeDir()", "Change the
> current Directory");
>
> 4) MainBar->AddButton("Display the Histo", "shoHistos()", "Display the
> Histos");
>
> 5) MainBar->AddButton("Quit session", "exit();", "Close the
> controlBar");
>
> 6) MainBar->Show();
>
> 7) theApp->Run();
> 8) delete theApp;
> 9) ...
>
> when I run it and press the first button it says:
> Error: Incorrect referencing of $nameFile FILE:/var/tmp/aaaa10082
> LINE:1
> Error: Incorrect referencing of $f FILE:/var/tmp/aaaa10082 LINE:1
> *** Interpreter error recovered ***
>
> but the two vars nameFile and f are well defined (I print it).
>
> If I press the "Quit session" button i get such error:
> (int)0
> *** Interpreter error recovered ***
> ...

In your definition of button 1, you have two arguments to your function
shoContent:
I assume that nameFile is a global somewhere defined as char*.
What is the second parameter f?
Assuming a global variable nameFile and a global say integer f
char * nameFile = "myfile.root";
int f = 10;
Interactively, you can do;
shoContent(nameFile,f);
and you can have a similar statement in the action of your button.
Note that you should have
shoContent(nameFile,f)
and not
shoContent(*nameFile,f)

Looking at your definition of this controlbar, I have the impression
that you are trying to do the same as the standard ROOT browser.
If you want to browse through a ROOT file containing any kind
of objects: histograms, Trees, tracks,etc, you do
TFile f("myfile.root")
TBrowser b
Then you can click on the item "ROOT files". You can go up and down
in your directory tree, clicking on histogram icons to display
the histogram, or use the right mouse button to get a context menu.

Rene Brun