[size=150]Dear All happy new year!
My problem is the following:
I drew TGLabel widget.
I want to read in a file (.dat) a certain number of data and display this number in the widget Label.
but my program says that, there is an syntax error and I have several times checked the program and I do not understand why there is this error.
Can somebody help me to check my scrip to tell me what does not go well?
Thanks for your attention,
[code]#include <TApplication.h>
#include <TGClient.h>
#include <TGButton.h>
#include <TGFrame.h>
#include <TGLayout.h>
#include <TGWindow.h>
#include <TGLabel.h>
#include <TGNumberEntry.h>
#include <TString.h>
#include “Riostream.h”
void histo();
class MyMainFrame : public TGMainFrame {
private:
TGLabel *fLabel515;
public:
MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
virtual ~MyMainFrame();
void DoLabel(nlines) ;
ClassDef(MyMainFrame, 0)
};
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h): TGMainFrame(p, w, h)
{
this->SetLayoutBroken(kTRUE);
TGFont ufont; // will reflect user font changes
ufont = gClient->GetFont("--Arial-bold-r---24-------*");
TGGC *uGC; // will reflect user GC changes
// graphics context changes
GCValues_t vall515;
vall515.fMask = kGCForeground | kGCBackground | kGCFillStyle | kGCFont | kGCGraphicsExposures;
gClient->GetColorByName("#000000",vall515.fForeground);
gClient->GetColorByName("#c0c0c0",vall515.fBackground);
vall515.fFillStyle = kFillSolid;
vall515.fFont = ufont->GetFontHandle();
vall515.fGraphicsExposures = kFALSE;
uGC = gClient->GetGC(&vall515, kTRUE);
ULong_t ucolor; // will reflect user color changes
gClient->GetColorByName("#3399ff",ucolor);
TGLabel *fLabel515 = new TGLabel( this,“1000”,uGC->GetGC(),ufont->GetFontStruct(),kChildFrame,ucolor);
fLabel515->SetTextJustify(36);
fLabel515->SetMargins(0,0,0,0);
fLabel515->SetWrapLength(-1);
this->AddFrame(fLabel515, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2));
fLabel515->MoveResize(16,8,192,72);
this->SetMWMHints(kMWMDecorAll,
kMWMFuncAll,
kMWMInputModeless);
this->MapSubwindows();
this->Resize(this->GetDefaultSize());
this->MapWindow();
this->Resize(256,101);
histo();
}
void MyMainFrame::DoLabel(nlines)
{
cout<<“val =”<<nlines<<endl;
fLabel515->SetText(Form("%d",nlines));
this->Layout();
}
void histo( )
{
ifstream in;
in.open(“essai.dat”);
Float_t x;
Int_t nlines = 0;
TH1F *h1 = new TH1F(“h1”,“x distribution”,100,19000,21000);
while (1) {
in >> x ;
if (!in.good()) break;
h1->Fill(x);
nlines++;
}
in.close();
TCanvas *C1 = new TCanvas("1X ",“1X”,1);
h1 -> Draw();
MyMainFrame::DoLabel(nlines);
//above, the programme refuses to allow me to use “nlines” as argument. Why ?
}
void test1()
{
new MyMainFrame(0,100,100);
}[/code][/code][/size]