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: <just80n@gmail.com>
Date: Tue Dec 20 2005 - 16:51:02 CET

guys... just some more help :

here is my final proc :

proc DYN_ex {COMMAND} \
   {
      global OUTPUT
      set OUTPUT ""
      rename puts _puts
      proc puts args { append ::OUTPUT $args "\n"; eval _puts $args}
      set retoureval [eval $COMMAND]
      rename puts {}
      rename _puts puts
      append OUTPUT $retoureval
      return $OUTPUT
   }

I have also a
proc choucroute{} {
  puts "abc def"
  puts "ghi jkl"
 return
}

when I launch this proc using DYN_ex, I get

% DYN_ex choucroute
qdsfsd 33
qdsfsd 4444 4
{qdsfsd 33}
{qdsfsd 4444 4}
choucroute

the last 3 lines are the "return from DYN_ex";

First, how to get rid of the "{" "}" ....

Then, if I send a wrong command: DYN_ex bidule for instance (assuming
bidule does not exists)
DYN_ex will return in the middle of its execution
(at line : set retoureval [eval $COMMAND] to be precise)
and won't complete the last critical steps:
      rename puts {}
      rename _puts puts

... how can I handle that?

thanks!
Received on Fri Dec 23 19:02:30 2005