Search code examples
tcl

Can anyone tell me why Tcl fails to simply read a specific file? Also the contents of the file fails when doing a string length


The following 2 lines never return and no error is thrown using wish.exe. I have tried in tcl 8.4 and 8.6. File is successfully read with node.

set fp [open "test.lst" r];
 
set file_data [read $fp];

Ran out of memory trying to paste the contents of the file so here is a download link to test.lst

https://nextcloud.wardbenn.com/s/znE32yTTaGjm5wL

fconfigure -translation binary -buffersize 10000000;

also fails


Solution

  • When running commands interactively, tclsh and wish will print the result of each command. A read command on a 91MB file produces a lot of output, which can make displaying it very slow. To prevent the printing of the result of a command, add a semicolon and a second command that produces very little output. Then that output will be printed instead:

    % set fp [open "test.lst" r]
    file6
    % set file_data [read $fp];list
    % string length $file_data
    95513423