For Programmers: Free Programming Magazines  


Home > Archive > Tcl > April 2007 > how to suppress set command output ??









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to suppress set command output ??
nishit.gupta@st.com

2007-04-25, 7:07 pm

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

2007-04-25, 7:07 pm

On 25 Apr 2007 07:01:45 -0700, nishit.gupta@st.com wrote:

>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

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
Bryan Oakley

2007-04-25, 7:07 pm

Helmut Giese wrote:
> On 25 Apr 2007 07:01:45 -0700, nishit.gupta@st.com wrote:
>
> 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


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.janssen@gmail.com

2007-04-25, 7:07 pm

On 25 Apr 2007 07:01:45 -0700, nishit.gupta@st.com wrote:

>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


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

2007-04-25, 7:07 pm

On Wed, 25 Apr 2007 14:20:36 GMT, Bryan Oakley
<oakley@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

2007-04-26, 4:16 am

The most simplest way I know is:
set data [read $f]; list
as [list] with no arguments returns "" :^)

Larry W. Virden

2007-04-26, 7:08 pm

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.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com