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 - 16:05:54 CET

Bryan Oakley <oakley@bardo.clearlight.com> wrote:
> just80n@gmail.com wrote:
>> I have a custom interpreter which people will feed with groups of
>> custom commands (procs ...). [I don't have power over the contents of
>> the procs, but I can do smthg after or before each one]
>> a proc looks typically like this :
>> proc gimmedat {} {
>> puts [date_fc -d]
>> bid_uch_pinct ab
>> puts [date_fc -h]
>> bid_uch_pinct cd
>> puts [date_fc -d]
>> bid_uch_pinct ef
>> puts [date_fc -h]
>> }
>> I'd like to grabb ALL the results outputed by a proc into a single
>> string and send this to another place via a socket...

> It sounds like all you need to do is redefine 'puts' to do it's normal
> job as well as append the string to a buffer. Then you simply need to
> flush the buffer when the proc is finished running.

Since he wrote "ALL" in capitals, I'd have guessed he wanted to
also record each "bid..."'s result.

My guess would be to not call the procedure gimmedat,
but instead use info body gimmedat to get the procedures
body as string (unless of course you already have it that
way), split it by "\n", and eval/uplevel each line individually.

If the procedures are really that simply structured, this might be
a feasible way.
Received on Fri Dec 23 19:02:10 2005