Probably a C++ issue, cannot solve!

Creating 4 canvases in a loop,

  1. This complete session works interactively, just two commands create 4 canvases:
    root [0] TCanvas c[10];
    root [1] for (Int_t j=1;j<5;j++){TCanvas c[j] = new TCanvas(Form(“name_%02d”,j),Form(“Canvas#%02d”,j),100j,100
    j,800,600);c[j]->Divide(2,2);}
    root [2] .q

  2. root -x trick.cxx fails with the following file:
    void trick(){
    cout << “v11 Simulation Analysis” << endl ;
    //TCanvas *c[10];
    static const unsigned ten = 10;
    TCanvas c[ten];
    for (Int_t j=1;j<5;j++) { TCanvas c[j] = new TCanvas(Form(“name_%02d”,j),Form(“Canvas#%02d”,j),100j,100
    j,800,600);
    c[j]->Divide(2,2);}
    }

Error message:
Error: Non-static-const variable in array dimension trick.cxx:6:
(cint allows this only in interactive command and special form macro which
is special extension. It is not allowed in source code. Please ignore
subsequent errors.)
*** Interpreter error recovered ***

Only the first canvas is drawn.

Thanks for a hint.
Jacques

Yeah, it’s a C++ issue, the basic syntax.

[quote]Creating 4 canvases in a loop,

  1. This complete session works interactively, just two commands create 4 canvases:
    root [0] TCanvas c[10];
    root [1] for (Int_t j=1;j<5;j++){TCanvas *c[j] = new TCanvas(Form(“name_%02d”,j),Form(“Canvas#%02d”,j),100
    j,100*j,800,600);c[j]->Divide(2,2);}
    root [2] .q
    [/quote]

First, you declare TCanvas * c[10], ok.
Now you want to initialize it in a loop -
you do not need ‘TCanvas *’, what you have - is an invalid expression, use just c[j] = …

 for (Int_t j=1;j<5;j++){c[j] = new .......

In the second case you have the same problem.