_ROOT Version: 6.18/04
_Platform: Linux Kubuntu
_Compiler: VS Code
I have a question about TControlBar’s working principle and don’t know how to search this info appropriately.
My Assumptions/Knowledge:
I know that the main cycle is “main()” (or the name of the .C file I’m working on) and it should run only once.
However, ControlBar gives me an opportunity to call other functions when the cycle is over.
Some Example
Now, when I run the code provided below - main cycle prints 0 (the value of the “manipulate”).
Next, if I try to print manipulate again via “Button 3” it gives me error (as I understand the variable doesn’t exist any more).
However, If I press “Button2” and afterwards “Button3” - root prints the correct integer.
My questions:
- Have I made any mistakes in my assumptions
- How it is possible (How it works, where is the data stored etc) to print integer if I press “Button2” -> “Button3”
“Bonus” Question:
As I understand TControlBar and main cycle processes can run in parallel.
How can I make main cycle to be “paused”, wait for the TControlBar procedures to be over and continue afterwards
void bla()
{
cout << "bla" << endl;
}
void main()
{
int manipulate = 0;
TControlBar *cbInit = new TControlBar("vertical", "Initialisation");
cbInit->AddButton("button 1", "bla();", "Auto scan");
cbInit->AddButton("Button 2", "manipulate = 2;", "Auto scan");
cbInit->AddButton("Button 3", "cout << manipulate << endl;", "Auto scan");
cbInit->Show();
cout << manipulate << endl;
}