[ROOT] Calling macro from method

From: cstrato (cstrato@aon.at)
Date: Sun Aug 04 2002 - 15:37:34 MEST


Dear Rooters

Root offers the nice possibility to execute macros from user code. As
far as I understand, this is ultimately done by calling
gROOT->ProcessLine() or gInterpreter->ProcessLine().

My question is, if I can also call a macro from a class method, where
the macro needs to have access to the class members. For example:

ClassA: public TNamed {
private:
      float fX;
      float fY;
public:
      void DoSomething( int n);
      void DoMacro(const char *macro, int n);
      int    GetX() {return fX;}
      void SetY(float y) {fY=y;}
}

The main program does:
Class *a=new ClassA();
a->DoSomething(3);
a->DoMacro(".x MyMacro.C+", 3);

where the macro MyMacro should be able to access both fX and n:
MyMacro()  // or: MyMacro(int n) ?
{
      float x=this->GetX();  //??
      float y=x*n;
      this->SetY(y);
}

Is this in principle possible, and what would be the best way to do it?

Thank you in advance for your help

Best regards
Christian
_._._._._._._._._._._._._._._._._
C.h.r.i.s.t.i.a.n S.t.r.a.t.o.w.a
V.i.e.n.n.a         A.u.s.t.r.i.a
_._._._._._._._._._._._._._._._._



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:03 MET