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

multiple assigning and && in a if...

0 views
Skip to first unread message

ma...@mafg.m.isar.de

unread,
Dec 13, 1998, 3:00:00 AM12/13/98
to
'llo everybody...

Is it possible to assign a value to many vars in the same line?

Something like: set {mickey donald minnie} 0

:-?

And is it possible something like this:

if {(cond1) && (cond2)} {
puts stdout "yeah, it's possible!"
}

Thanks in advance!

Manu
--
Emanuele D'Arrigo
3D Animator & Modeller
Munich Animation film GmbH
Germany

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

Tim Trainor

unread,
Dec 13, 1998, 3:00:00 AM12/13/98
to
ma...@mafg.m.isar.de wrote:
>
> 'llo everybody...
>
> Is it possible to assign a value to many vars in the same line?
>
> Something like: set {mickey donald minnie} 0

Yes :

set varnames [list var1 var2 var3] ; foreach var $varnames {set $var
0}

technically ,it's all on one line, but in two commands.

> And is it possible something like this:
>
> if {(cond1) && (cond2)} {
> puts stdout "yeah, it's possible!"
> }

Yes.

ma...@mafg.m.isar.de

unread,
Dec 14, 1998, 3:00:00 AM12/14/98
to
In article <36743825...@spamless.berkshire.net>,
Tim Trainor <ttra...@spamless.berkshire.net> wrote:

> set varnames [list var1 var2 var3] ; foreach var $varnames {set $var 0}
>
> technically ,it's all on one line, but in two commands.

Ah, ok... it's not as compact as i would. No prob.

> > And is it possible something like this:
> >
> > if {(cond1) && (cond2)} {
> > puts stdout "yeah, it's possible!"
> > }
>
> Yes.

Strange... last time i tried it didn't work... =(

Thanks anyway.

Paul Duffin

unread,
Dec 14, 1998, 3:00:00 AM12/14/98
to
ma...@mafg.m.isar.de wrote:
>
> In article <36743825...@spamless.berkshire.net>,
> Tim Trainor <ttra...@spamless.berkshire.net> wrote:
>
> > set varnames [list var1 var2 var3] ; foreach var $varnames {set $var 0}
> >
> > technically ,it's all on one line, but in two commands.
>
> Ah, ok... it's not as compact as i would. No prob.
>
> > > And is it possible something like this:
> > >
> > > if {(cond1) && (cond2)} {
> > > puts stdout "yeah, it's possible!"
> > > }
> >
> > Yes.
>
> Strange... last time i tried it didn't work... =(
>
> Thanks anyway.

It does not work for textual boolean values. e.g. false, true.

--
Paul Duffin
DT/6000 Development Email: pdu...@hursley.ibm.com
IBM UK Laboratories Ltd., Hursley Park nr. Winchester
Internal: 7-246880 International: +44 1962-816880

Bryan Oakley

unread,
Dec 14, 1998, 3:00:00 AM12/14/98
to
ma...@mafg.m.isar.de wrote:
>
> 'llo everybody...
>
> Is it possible to assign a value to many vars in the same line?
>
> Something like: set {mickey donald minnie} 0

What I sometimes do is this:

set mickey [set donald [set minnie 0]]]

But I don't find it particularly readable.


--
Bryan Oakley mailto:oak...@channelpoint.com
ChannelPoint, Inc. http://purl.oclc.org/net/oakley

Tim Trainor

unread,
Dec 14, 1998, 3:00:00 AM12/14/98
to
ma...@mafg.m.isar.de wrote:

> > > And is it possible something like this:
> > >
> > > if {(cond1) && (cond2)} {
> > > puts stdout "yeah, it's possible!"
> > > }
> >
> > Yes.
>
> Strange... last time i tried it didn't work... =(
>
> Thanks anyway.

ok, I did test this before I replied, so look at this:

set x 1 ;# a TRUE value
set y 1 ;#another TRUE

if { $x && $y } {puts stdout "yeah, it's possible"}
tcl> yeah, it's possible

or,
if {[info exists x] && [info exists y]} {puts stdout "OK"}
tcl> OK

or just to make sure,

if {[info exists x] && [info exists foobar]} {puts stdout "yeah, sure"}
tcl>

(no output, && evaluted to FALSE)

ma...@mafg.m.isar.de

unread,
Dec 15, 1998, 3:00:00 AM12/15/98
to
In article <3675411D...@channelpoint.com>,
Bryan Oakley <oak...@channelpoint.com> wrote:

> > Something like: set {mickey donald minnie} 0
> What I sometimes do is this:
> set mickey [set donald [set minnie 0]]]
> But I don't find it particularly readable.

I agree, but the idea is genial. =)

Richard.Suchenwirth

unread,
Dec 21, 1998, 3:00:00 AM12/21/98
to Tim Trainor
Tim Trainor wrote:

>
> ma...@mafg.m.isar.de wrote:
> > Is it possible to assign a value to many vars in the same line?
> > Something like: set {mickey donald minnie} 0
>
> Yes :

> set varnames [list var1 var2 var3] ; foreach var $varnames {set $var
> 0}
>
> technically ,it's all on one line, but in two commands.
Even simpler, and in one statement:
foreach i {mickey donald minnie} {set $i 0}

0 new messages