I have writting a simple script (based on documentation example)
which create a ROOT file with an histogram (class TH1F) in it.
Then it read this file, find a TKey and draw thestogram.
1/ When executing this script in root with script processor:
root [] .x test.C
-> Error, a default canvas is displaying but not the histogram.
2/ When executing exacly same commands in root command line:
-> No error, a default canvas id displaying with the histogram.
code: test.C
{
gROOT->Reset();
//Create a pointer to an histograme
TH1F *h = new TH1F("histo1","histogram",100,-4,4);
// Fill it
h->FillRandom("gaus",1000);
// open a file and write the Array to the file
TFile f("$HOME/Root/files/demo.root","recreate");
h->Write();
f.GetListOfKeys()->Print();
TH1F *h = (TH1F*)f.Get("histo1");
// Draw the histogram
h->Draw();
Thanks,