Re: Syntax Error and I can't find it

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Tue, 30 Mar 2010 11:39:00 -0500


Hi Cedric,

You have 2 choice, either use 'new' :

     TGraphErrors *Kalib1 = new TGraphErrors( gDatKalibLen,Kalib1R,Kalib1S );

or use an unnamed script (in which case you will _not_ be able to use the compiler):

// Start of file
{

#include "/home/manday/Programs/lib/raupach/praktlib.h"

gROOT->SetStyle("Plain");
string baseDir = "/home/manday/Documents/University/Physik Praktikum/Akustik/Cassy/";
gStyle->SetOptFit();

TCanvas gCWegKalib1( "WegKalibration","Kalibration Wegaufnehmer" );

// Linearer Fit Wegaufnehmer
gCWegKalib1.SetGrid();
gCWegKalib1.SetFillColor( kWhite );

PraktLib *gDatKalib1 = new PraktLib( baseDir + "Kalibrierung.lab","cassy" );
const int gDatKalibLen = gDatKalib1->NumRows();

Double_t* Kalib1R = new Double_t[ gDatKalibLen ]; Double_t* Kalib1S = new Double_t[ gDatKalibLen ]; for( int i = 0; i<gDatKalibLen; i++ ) {

     Kalib1R[ i ]= gDatKalib1->ReadData( i,3 );
     Kalib1S[ i ]= gDatKalib1->ReadData( i,4 );
}

TGraphErrors Kalib1( gDatKalibLen,Kalib1R,Kalib1S ); // Kalib1.Fit( "pol1","W" );
Kalib1.Draw( );

}
// End of file

Cheers,
Philippe.

On 3/30/10 11:30 AM, Cedric Sodhi wrote:
> Hi Phillippe, no its not a missing declaration or definition of Kalib1
> - I dropped the line by accident and when I wanted to send out a
> correction you had already beaten me to it.
>
> However, wrapping the whole thing in a void fixed the error. Great,
> thank you CINT for such meaningful error messsages.
>
> Nonetheless wrapping it in a void had some other negative sideeffects:
> Whereas before a canvas poppep up upon creating it, now nothing happens,
>
> not even on Kalib1.Draw( ). THe corrected source code (no lines
> dropped) here:
>
>
> #include "/home/manday/Programs/lib/raupach/praktlib.h"
>
> void auswertung( ) {
>
> gROOT->SetStyle("Plain");
> string baseDir = "/home/manday/Documents/University/Physik
> Praktikum/Akustik/Cassy/";
> gStyle->SetOptFit();
>
> TCanvas gCWegKalib1( "WegKalibration","Kalibration Wegaufnehmer" );
>
> // Linearer Fit Wegaufnehmer
> gCWegKalib1.SetGrid();
> gCWegKalib1.SetFillColor( kWhite );
>
> PraktLib *gDatKalib1 = new PraktLib( baseDir +
> "Kalibrierung.lab","cassy" );
> const int gDatKalibLen = gDatKalib1->NumRows();
>
> Double_t* Kalib1R = new Double_t[ gDatKalibLen ];
> Double_t* Kalib1S = new Double_t[ gDatKalibLen ];
> for( int i = 0; i<gDatKalibLen; i++ ) {
> Kalib1R[ i ]= gDatKalib1->ReadData( i,3 );
> Kalib1S[ i ]= gDatKalib1->ReadData( i,4 );
> }
>
> TGraphErrors Kalib1( gDatKalibLen,Kalib1R,Kalib1S );
> // Kalib1.Fit( "pol1","W" );
> Kalib1.Draw( );
>
> }
>
> Philippe Canal wrote:
>> Hi Cedric,
>>
>> To get better error message you can ask the compiler by replacing:
>>
>> root [0] #include "auswertung.cpp"
>>
>> with
>>
>> root [0] #include "auswertung.cpp+"
>>
>> However you would need to turn this file in a proper C++ file (as
>> oppose to using the CINT shortcuts).
>>
>> Nonetheless, it seems that the problem is with the line:
>>
>> Kalib1.Draw( );
>>
>> where Kalib1 is probably not properly defined.
>>
>> Cheers,
>> Philippe.
>>
>> PS. The recommend way to use you script is:
>>
>> root [] .x auswertung.cpp
>>
>> and the best way to write it is:
>>
>> #include "/home/manday/Programs/lib/raupach/praktlib.h"
>>
>> void auswertung() {
>> gROOT->SetStyle("Plain");
>> string baseDir = "/home/manday/Documents/University/Physik
>> Praktikum/Akustik/Cassy/";
>> gStyle->SetOptFit();
>>
>> TCanvas gCWegKalib1( "WegKalibration","Kalibration Wegaufnehmer" );
>>
>> // Linearer Fit Wegaufnehmer
>> gCWegKalib1.SetGrid();
>> gCWegKalib1.SetFillColor( kWhite );
>> PraktLib *gDatKalib1 = new PraktLib( baseDir +
>> "Kalibrierung.lab","cassy" );
>> const int gDatKalibLen = gDatKalib1->NumRows();
>>
>> Double_t* Kalib1R = new Double_t[ gDatKalibLen ];
>> Double_t* Kalib1S = new Double_t[ gDatKalibLen ];
>> for( int i = 0; i<gDatKalibLen; i++ ) {
>> Kalib1R[ i ]= gDatKalib1->ReadData( i,3 );
>> Kalib1S[ i ]= gDatKalib1->ReadData( i,4 );
>> }
>>
>> Kalib1.Draw( );
>> }
>>
>> On 3/30/10 11:07 AM, Cedric Sodhi wrote:
>>> I'm sorry as I get the feeling that I seem to bombard the mailing
>>> list with questions which appear trvial at best but CINT is driving
>>> me in-sane! I don't consider myself a bad programmer, actually I
>>> think I'm quite good at what I do although my last substancial
>>> experience with CPP lies a few years behind but that CINThing is
>>> getting the last iota of patience out of me. I got a deadline for
>>> tomorrow and CINT stops me at the simplest tasks! Nothing seems to
>>> work!
>>>
>>> Now, if anyone understand the following error message and can make
>>> the link to the (few lines long) source code, please let me know, I
>>> really need the help right now. The #included file in the #included
>>> file can be found here, but shouldnt be the reason for this (it
>>> better be not)
>>>
>>> >> If you are interested in trying this out you can find them packed
>>> here:
>>> >> http://accms04.physik.rwth-aachen.de/~praktapp/
>>> <http://accms04.physik.rwth-aachen.de/%7Epraktapp/> -> "Neue ROOT
>>> Routinen"
>>> >> Direct link for download:
>>> >> http://accms04.physik.rwth-aachen.de/~praktapp/root_new/
>>> <http://accms04.physik.rwth-aachen.de/%7Epraktapp/root_new/>
>>> >> Author(s) as mentioned on page.
>>>
>>> root [0] #include "auswertung.cpp" Converting
>>> file to csv-file...
>>> Starting conversion...
>>> Opening output file: /home/manday/Documents/University/Physik
>>> Praktikum/Akustik/Cassy/Kalibrierung.lab.out
>>> Opening input file...
>>> Checking file type by argument...
>>> File type: CASSYLab file...
>>> Looping over file...
>>> Found 4 y columns...
>>> Done!
>>> Reading file /home/manday/Documents/University/Physik
>>> Praktikum/Akustik/Cassy/Kalibrierung.lab.out...
>>> Error: Missing one of ',)' expected at or after line 18.
>>> Error: Unexpected end of file (G__fgetstream_template():2)
>>> auswertung.cpp:26:
>>> Error: Missing one of ',;{(' expected at or after line 26.
>>> Error: Unexpected end of file (G__fgetstream_template():2)
>>> auswertung.cpp:26:
>>> Error: Missing one of '{' expected at or after line 26.
>>> Error: Unexpected end of file (G__fignorestream():3) auswertung.cpp:26:
>>> *** Interpreter error recovered ***
>>> root [1]
>>> ______________________
>>>
>>> #include "/home/manday/Programs/lib/raupach/praktlib.h"
>>>
>>> gROOT->SetStyle("Plain");
>>> string baseDir = "/home/manday/Documents/University/Physik
>>> Praktikum/Akustik/Cassy/";
>>> gStyle->SetOptFit();
>>>
>>> TCanvas gCWegKalib1( "WegKalibration","Kalibration Wegaufnehmer" );
>>>
>>> // Linearer Fit Wegaufnehmer
>>> gCWegKalib1.SetGrid();
>>> gCWegKalib1.SetFillColor( kWhite );
>>> PraktLib *gDatKalib1 = new PraktLib( baseDir +
>>> "Kalibrierung.lab","cassy" );
>>> const int gDatKalibLen = gDatKalib1->NumRows();
>>>
>>> Double_t* Kalib1R = new Double_t[ gDatKalibLen ];
>>> Double_t* Kalib1S = new Double_t[ gDatKalibLen ];
>>> for( int i = 0; i<gDatKalibLen; i++ ) {
>>> Kalib1R[ i ]= gDatKalib1->ReadData( i,3 );
>>> Kalib1S[ i ]= gDatKalib1->ReadData( i,4 );
>>> }
>>>
>>> Kalib1.Draw( );
>>>
>>
>
Received on Tue Mar 30 2010 - 18:39:04 CEST

This archive was generated by hypermail 2.2.0 : Tue Mar 30 2010 - 23:50:02 CEST