Re: (newbie) storing outputs from all lines of procs into a string
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: (newbie) storing outputs from all lines of procs into a string

From: Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at>
Date: Mon Dec 19 2005 - 17:56:23 CET

just80n@gmail.com <just80n@gmail.com> wrote:
> I'll use this one but following code :
> proc ex {COMMAND} {

add here:
  global OUTPUT

> set OUTPUT ""
> rename puts _puts
> proc puts {args} { append OUTPUT $args "\n"; eval _puts $args }

add "::" as shown:
proc puts {args} { append ::OUTPUT $args "\n"; eval _puts $args }

> eval $COMMAND

add here:
  rename puts {}

> rename _puts puts
> return $OUTPUT
> }

Without the "global" and the "::", each part will
access a different variable, so you would have seen
nothing.

>...
> can't rename to "puts": command already exists
> in other words " rename _puts puts " fails.... a workaround?

Sorry, I forgot that rename doesn't work, if the target already exists.
The workaround is the added "rename puts {}" above.

With all the changes, I'd now expect it to work.
Received on Fri Dec 23 19:02:15 2005