Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-11-15
20:15 • Ticket [792990ffff] Redirect file output into variables status still Closed ... artifact: 6d791a0d75 user: elfring
05:55 • Closed ticket [792990ffff]. artifact: a9ba71d1d8 user: andreas_kupries
2004-07-27
18:45 • Ticket [792990ffff]: 4 changes artifact: 6be71ce1e0 user: elfring
2003-11-13
05:52 • Ticket [792990ffff]: 1 change artifact: 81c0fd08ee user: dgp
2003-09-21
23:52 • Ticket [792990ffff]: 4 changes artifact: 3b727105de user: elfring
2003-09-19
15:26 • Ticket [792990ffff]: 4 changes artifact: 53c5ec0d56 user: elfring
15:23 • Ticket [792990ffff]: 4 changes artifact: 49bfacad4c user: vincentdarley
15:17 • Ticket [792990ffff]: 4 changes artifact: 728fc1110f user: elfring
00:41 • Ticket [792990ffff]: 5 changes artifact: 95179554e0 user: vincentdarley
2003-08-23
22:53 • Ticket [792990ffff]: 4 changes artifact: 8b428aa120 user: elfring
2003-08-22
21:13 • Ticket [792990ffff]: 4 changes artifact: f1fc540248 user: elfring
20:49 • Ticket [792990ffff]: 4 changes artifact: 2a593df1e2 user: dgp
20:36 • Ticket [792990ffff]: 4 changes artifact: d6af7fb40e user: elfring
16:13 • Ticket [792990ffff]: 4 changes artifact: 81f4b91436 user: vincentdarley
07:47 • New ticket [792990ffff]. artifact: caa4eeb8de user: elfring

Redirect file output into variables

Closed / Duplicate792990ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 19 years ago
Descriptionplain2003-08-22 07:47:05
The PHP programming language provides output control 
functions 
(http://de.php.net/manual/en/ref.outcontrol.php, e. 
g. "ob_get_contents"). I would like to use similar 
functionality with TCL.

1. http://tcl.tk/man/tcl8.4/TclCmd/open.htm
I suggest to add a parameter that specifies a variable 
name.
open $fileName $access $permissions $varName
   or
open -var $Name $fileName $access $permissions

2. http://tcl.tk/man/tcl8.4/TclCmd/fconfigure.htm
I suggest to add an interceptor and options to switch 
the output into variables on and off on the fly.
fconfigure -setvar $Name $channelId
fconfigure -stopvar $Name $channelId
fconfigure -getcontents Buffer $channelId
vincentdarleyplain2003-08-22 16:13:21
Logged In: YES 
user_id=32170

It's not clear from what you write what the behaviour is
that you are seeking for these 4 new commands.  How about
looking at the man pages and adding to this feature request
a few sentences on each option describing what it actually
does and how it is used, perhaps with an example?
elfringplain2003-08-22 20:36:30
Logged In: YES 
user_id=572001

1. Open  a new file with the option that all data is written to 
or read from a TCL variable
Example:
if {![catch {open -var Debug stdout w} File]} \
 {
  # Some code to check in a "special" execution environment

  # Do something...
   puts "Surprise"

  # Work is done.
  close $File

  LogResult $Debug
 }


2. Catch a part of file processing
Example:
fconfigure -setvar Debug stdout

# Do something...
puts "Surprise"

fconfigure -stopvar Debug stdout
LogResult $Debug

# Display message to the normal target
puts "finished"

if [file isbuffering stdout] \
 {
  fconfigure -getcontents Buffer stdout
  LogResult $Buffer
 }


Is this little explanation useful?
dgpplain2003-08-22 20:49:24
Logged In: YES 
user_id=80530


so you are looking for a new channel
type that is backed by a variable?

Or are you looking for a new filesystem
type where the "files" are really variables?

Either one should be possible in an
extension given Tcl's current public API,
right?  Are you aware of missing interfaces?

The latter one might even be possible
entriely at the scritp level, making use
of the tclvfs package.
elfringplain2003-08-22 21:13:16
Logged In: YES 
user_id=572001

Can the requested functions be implemented by two 
techniques?
I've got no preferences. I would like both.
elfringplain2003-08-23 22:53:33
Logged In: YES 
user_id=572001

Has anybody tried to create a file system interface for variables before?
vincentdarleyplain2003-09-19 00:41:15
Logged In: YES 
user_id=32170

I suggest this be discussed on comp.lang.tcl, and then, if
some sort of consensus/design is reached, someone can write
a TIP.  It's all a bit vague and sourceforge isn't really
very convenient for making vague discussions more concrete.
elfringplain2003-09-19 15:17:56
Logged In: YES 
user_id=572001

1. How do you think about to create a companion topic 
for "http://mini.net/tcl/memchan" like it was done 
with "http://wiki.tcl.tk/source" for an other request?

2. What kind of convenience are you missing from 
SourceForge?
vincentdarleyplain2003-09-19 15:23:19
Logged In: YES 
user_id=32170

This bug report/feature request is quite invisible to the
Tcl community, unless someone is actively seeking it out.  A
discussion on the Wiki or comp.lang.tcl is much more visible
and likely to solicit more opinions and lead to a better
solution. After all, I'm the only one who has responded to
this at all. If you believe the idea is a good one, then
surely many people would be interested...
elfringplain2003-09-19 15:26:37
Logged In: YES 
user_id=572001

What is better: Wiki or newsgroup or both?
elfringplain2003-09-21 23:52:50
Logged In: YES 
user_id=572001

I started the discussion 
"http://groups.google.de/groups?group=comp.lang.tcl&selm=40ed1d8f.0309190825.12f4fac6%40posting.google.com".
dgp Ticket [792990ffff]: 1 change [History diff]2003-11-13 05:52:00
elfringplain2004-07-27 18:45:12
Logged In: YES 
user_id=572001

Is there anything in common 
with "http://dedasys.com/freesoftware/files/CacheOut.tgz"?
andreas_kupriesplain2007-11-15 05:55:30
Logged In: YES 
user_id=75003
Originator: NO

This is IMHO subsumed by the TIP #219 (http://tip.tcl.tk/219.html), "Tcl Channel Reflection API". This allows users to write a channel driver in Tcl which stores the written data to a variable, and/or reads from it.
Considered to be now a duplicate of http://sourceforge.net/tracker/index.php?func=detail&aid=1025294&group_id=10894&atid=310894
elfringplain2007-11-15 20:15:02
Logged In: YES 
user_id=572001
Originator: YES

Is a channel driver available for the suggested redirection already?
http://wiki.tcl.tk/2701
Log in (anonymous is fine) to add a comment.