Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to suppress set command output ??

431 views
Skip to first unread message

nishit...@st.com

unread,
Apr 25, 2007, 10:01:45 AM4/25/07
to
Hi all,
i am new to tcl and having problem with set command.
Normally whenever one uses set command to initialize a variable its
value is also shown on console
i.e.
set temp_var [read $file]
--> all the content of the file will be listed out here now (which i
want to suppress)
my file consists of around 300000 lines which i do not want to listed
out because
i am using this command in a console of a tool (simvision) and after
running this command to
read complete file in a temp variable my console is getting hung.
Is their any way so that i can suppress the output of set command
thanx in advance

Helmut Giese

unread,
Apr 25, 2007, 10:12:45 AM4/25/07
to

Hi,
just follow it with a comand which prints nothing like
set temp_var [read $file] ; puts ""
or maybe even
set temp_var [read $file] ; puts [string range $temp_var 80]
which shows you the first 80 characters from the file you just read.
HTH
Helmut Giese

nishit...@st.com

unread,
Apr 25, 2007, 10:09:50 AM4/25/07
to

Bryan Oakley

unread,
Apr 25, 2007, 10:20:36 AM4/25/07
to

When I'm in a similar situation I sometimes do something like this:

% string length [set temp_var [read $file]]

You could also define your own silent set command:

proc sset {varname value} {
uplevel [list set $varname $value]
return ""
}

--
Bryan Oakley
http://www.tclscripting.com

mpc.j...@gmail.com

unread,
Apr 25, 2007, 11:20:58 AM4/25/07
to
On 25 Apr 2007 07:01:45 -0700, nishit...@st.com wrote:

The last result is always shown in the console when using it
interactively. The trick is therefore to not make that read the last
result. You could use:

set temp_var [read $file] ; puts ok

This will show ok and not the contents of the tempvar.

Mark

Helmut Giese

unread,
Apr 25, 2007, 12:01:10 PM4/25/07
to
On Wed, 25 Apr 2007 14:20:36 GMT, Bryan Oakley
<oak...@bardo.clearlight.com> wrote:

>When I'm in a similar situation I sometimes do something like this:
>
>% string length [set temp_var [read $file]]

Hey, that's cute - could convey some useful information.

suchenwi

unread,
Apr 26, 2007, 3:37:15 AM4/26/07
to
The most simplest way I know is:
set data [read $f]; list
as [list] with no arguments returns "" :^)

Larry W. Virden

unread,
Apr 26, 2007, 11:35:33 AM4/26/07
to
On Apr 25, 10:01 am, nishit.gu...@st.com wrote:
.
> Normally whenever one uses set command to initialize a variable its
> value is also shown on console

For someone wandering by, this behavior only occurs when one is
interactively working with tcl. Executing the commands within a file
do not have this behavior.

0 new messages