Hi Paul, SetCommand() can only be used to call methods that are know to the CINT interpreter. That means that you need to export PlotGraph() to CINT via the rootcint procedure. Also c is not directly known in the interpreter if the global symbol has not been exported. Please check the user guide on how all this can simply be done. Cheers, Fons. On Thu, 2002-04-11 at 13:44, Paul Dixon wrote: > Hi, > > I'm trying to build a trivial GUI so that when I click on different > buttons, different plots are generated. My first go is to have a button > that plots the example sin(x)/x. > > >From some code posted earlier on roottalk: > > I have a button defined (b) that acts as a quit button: > > TGButton *b = new TGTextButton(&mf, "Quit"); > b->SetCommand("gApplication->Terminate()"); > > which works fine. > > but if I change this to run my PlotGraph function: > > b->SetCommand("PlotGraph()"); > > where PlotGraph is: > > void PlotGraph(void){ > TCanvas *c1 = c->GetCanvas(); > TF1 f1("func1", "sin(x)/x", 0, 10); > f1.Draw(); > c1->Update(); > } > > *c is defined before main{} as > > TRootEmbeddedCanvas *c = new TRootEmbeddedCanvas("Canvas", &mf, 600, 400); > > which I believed made c global (therefore accessable from any other > function)... > > When I compile the code and run it, I get: > > [] ~/root $ ./canvasgui > Error: Function PlotGraph() is not defined in current scope > FILE:/tmp/filezX8DtE_cint LINE:1 > > Which has me (a c++ newbie) stumped. Presumably I've missed out some > important step... > > Thanks in advance, > Paul > > -- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7679480
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:49 MET