I dare to create a companion request for the
topic "Redirect file output into variables"
(https://sourceforge.net/tracker/?
func=detail&aid=792990&group_id=10894&atid=36089
4).
Can a memory channel be developed that can read from
and write into TCL variables?
Logged In: YES
user_id=202636
I believe this is already achieved by the memchan channel.
If you are writing to a variable, you are basically naming
the buffer used to back the channel. The memchan channel is
a buffer backed channel. You can read the data out of it
using [seek $f 0; read $f].
So:
% set f [memchan]
mem0
% puts $f Hello
% set Data [seek $f 0][read $f]
Hello
% puts $f World
% set Data [seek $f 0][read $f]
Hello
World
If you wanted something a but more tightly tied to a
variable - for instance a list that was appended to for each
line written to the channel, then a 'transform' should do
the job. The transform command is implemented by the Trf
extension and lets you create a new channel type in script.
Your script is called with flags on initialisation, read,
write, close etc. The tcllib rc4 package code has a Trf
transformation to create a transparently encrypting channel.
I don't believe there is a need for a new channel type
beyond those already present to satisfy this request. (If
I'm wrong, then lets re-open this tracker item).
Logged In: YES
user_id=572001
Your example does not fit to my request.
Did you look at my previous request "Redirect file output into
variables"?