How to draw a macro (class TMacro) in a pad

Hello,
In the class description of TMacro, it is mentioned that a macro can be drawn in a pad. I understand it can be printed on screen by mymacro->Print(), but I don’t know how to draw it on a pad. Anybody can tell?

Thanks,
Zhiyi.
ROOT: 5.08
Linux: mandrake 10.2

If you do
macro->Draw();

when the pad/canvas need to be painted, the macro will be
automatically executed. macro-PAint calls macro->Exec

Rene

Yes, I have tried before posting my question here, when I use

macro->Draw(),

to try to draw macro on a pad, my root crashed. Output is:

[zhiyil@d-r15229 job.Fermilab200606]$ root testTMacro.C
root [0]
Processing testTMacro.C…
: created default TCanvas with name c1

*** Break *** segmentation violation
[zhiyil@d-r15229 job.Fermilab200606]$

Attached is a simple code to test it.

Cheers,
Zhiyi.
testTMacro.C (225 Bytes)

Where is your TMacro?

To execute a standard script simply do .x testMacro.C

When drawing a TMacro, it does not make sense to use statements
like h->Draw() that will clear the pad (hence the TMacro)

Rene

Well, I am confused. :frowning:

Attached is a root file containing a TMacro named “logfile”. I cannot draw my TMacro by logfile->Draw() after opening the file, it makes sense?

Zhiyi.
testTMacro.root (1.57 KB)

I am confused too.
What is the point in executing/drawing a macro containing one hundred lines like
’I am one line of TMacro"

Rene

Okay, I get it. I have to claim that my aim to use TMacro and store it in my root file is not for storing an eact macro, instead a file something like log file. I mean I don’t wanna execute it although I store it as a macro class, what I wanna do is just a log file (a text file is enough for me). Several days ago, I posted a question here: how to store a text file in a root file so that I can record some corresponding information with this root file, somebody suggested me to use TMacro to store a text file.

So, my question is how to view this text file (with a macro format in a root file) instead of by m->Print()?

see documentation of class TMacro::Browse at
root.cern.ch/root/htmldoc//TMacr … cro:Browse
This is only implemented in the CVS head.

In the coming days, the CVS version will accept an automatic view
of a TMacro in the local ROOT Editor.

Rene