[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] Printing from C++ through tcl



Thank you for the reply,

There is not really a reason for using the second option. I use the evalf
function in other parts of my agent and thought it might also be a good idea to
print through tcl. I guess I was wrong.

Nick

Padmaparna Haldar wrote:

> On Tue, 22 May 2001, Nikolaos Katsarakis Austauschstud. (M. Schweigel) wrote:
>
> > Hello,
> >
> > I am trying to print some information messages from my new agent.
> >
> > There are two ways to do this.
> >
> > 1) include the stdio.h library in my C++ code and use a usual printf
> > command, eg
> >
> > #include <stdio.h>
> >
> > printf("My number is: %d\n",number);
> >
> > 2) use the tcl evalf function, e.g.
> >
> > Tcl& tcl = Tcl::instance();
> > tcl.evalf("puts stdout \"My number is: %d\n\"",number);
> >
> > But the second command is much more complicated, as I have to include
> > the command_puts stdout_ and the _\"_ to protect the string. Is there an
> > easier way of printing through tcl (maybe through resultf), or do I just
> > have to use the good old printf?
>
> Is there any compelling reason to use the 2nd option?
> can you pl explain.
> --Padma
>
> >
> > Thanks
> >
> > Nikos
> >
>
> --
> ------------------------------------------------
> Be true to your work, your word, and your friend.
> --Thoreau
>
> Padmaparna Haldar