Hi Ole, On Mon, 2 Sep 2002 18:27:37 +0200 Ole Streicher <ole@ifh.de> wrote concerning "[ROOT] Cint and loops?": > Hi! > > I have a problem when using interactive cint. The following doesn't > work for me: > > root [0] TH1F *hist = new TH1F("i", "i", 1000, 0., 1000.); > root [1] for (Int_t j = 0; j < 1000; j++) { > !!!Bad command input. Ignored!!! > root [2] for (Int_t j = 0; j < 1000; j++) > root [3] { > end with '}'> hist->Fill(j); > end with '}'> } > (Int_t)(-1) > root [4] hist->Print(); > TH1.Print Name= i, Entries= 1, Total sum= 0 > > For me, it is not clear why I can't use the opening brace at the same > line as the for (; ; ) statement. > > If I set the opening brace to the next line, I dont get the histogram > filled properly: It has just one entry instead of 1000. > > What is the reason for that and how can I write this loop at command > line? > > (Sorry for all these questions, but I dont have an "expert" on my site > who may help with the trivial questions) Well, you needn't look that far. The start-up message of ROOT says: ******************************************* * * * W E L C O M E to R O O T * * * * Version 3.03/08 20 August 2002 * * * * You are welcome to visit our Web site * * http://root.cern.ch * * * ******************************************* FreeType Engine v1.x used to render TrueType fonts. Compiled for linux with thread support. CINT/ROOT C/C++ Interpreter version 5.15.53, Aug 15 2002 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |||||||||||||||||||||||||||||||||||||||| hence the following will work/not work: root [0] { for (Int_t i = 0; i < 100; i++) { end with '}'> cout << "this is line # " << i << endl; end with '}'> } end with '}'> } this is line # 0 this is line # 1 this is line # 2 ... this is line # 99 root [1] if (i == 100) { cout << "Hello world" << endl; } Hello world (class ostream)1087514176 root [2] if (i == 100) { // This gives an error !!!Bad command input. Ignored!!! root [3] { if (i == 100) { end with '}'> cout << "Hello again" << endl; end with '}'> }} Hello again (class ostream)1087514176 root [4] if (i == 100) { \ > cout << "Hello world" << endl; \ > } !!!Bad command input. Ignored!!! If the ROOT version of CINT used the GNU readline library, this probably would be ok, depending on how Masa uses that library. Yours, ____ | Christian Holm Christensen |_| | ------------------------------------------------------------- | | Address: Sankt Hansgade 23, 1. th. Phone: (+45) 35 35 96 91 _| DK-2200 Copenhagen N Cell: (+45) 24 61 85 91 _| Denmark Office: (+45) 353 25 305 ____| Email: cholm@nbi.dk Web: www.nbi.dk/~cholm | |
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:06 MET