Nп/п : 7 из 100
 От   : Helmut Giese                        2:5075/128        28 авг 23 00:02:29
 К    : All                                                   28 авг 23 01:06:02
 Тема : How to use `dup` from TclX
----------------------------------------------------------------------------------
                                                                                 
@MSGID: <cbhnei1nu5kfqveh27f4m48r61c8h8cudp@4ax.com>
c90e4119
@REPLYADDR Helmut Giese <hgiese@ratiosoft.com>
@REPLYTO 2:5075/128 Helmut Giese
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID:
<cbhnei1nu5kfqveh27f4m48r61c8h8cudp@4ax.com>
@TZUTC: 0200
@TID: FIDOGATE-5.12-ge4e8b94
Hello out there,
I have some data that I use to analyse the behaviour of my program.
Now I thought it would be a good idea to  include this data in my
repository.
But the data is generated by using `puts` so I would need a way to
redirect `puts` to `stdout`.
I found `dup` from TclX but apparently I cannot use it correctly. Here
is my (compressed) attempt:
---
package require Tclx

proc dumpTree {data} {
    puts $data
}

proc process {data} {
    set fName dump.txt
    if {[file exists $fName]} {
        file delete $fName
    }
    set fd [open $fName w]
    dup $fd stdout
    dumpTree $data
    close $fd
}
process "some data"
---
The file `dump.txt` is generated but it is empty. Moreover running
this programm repeatedly produces the error
 error deleting "dump.txt": permission denied

Any help on correcting my mistake(s) will be greatly appreciated.
Helmut
--- Forte Free Agent 1.93/32.576 English (American)
 * Origin: ratiosoft (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх