[NTLUG:Discuss] OT: Tcl/Tk question
Allen Flick
AllenFlick at UTDallasAlumni.com
Fri Jul 23 11:14:45 CDT 2004
Greg Edwards wrote:
> fredjame wrote:
> > The following procedure is working, but I have noted that 'string match
> > ...' already returns 1 on a match and 0 on no match. So my question is
> > how to rewrite this without the 'if ...' and the extra 'return'? - it is
> > a syntax question actually.
> > Thank you in advance for any help you may be able to offer.
> > Regards
> > Fred James
> >
> > proc MatchColor {color} {
> > If [string match *$color* [getMem Document ChannelNames]] {
> > return 1
> > }
> > return 0
> > }
> >
> >
>
> How about
>
> Proc MatchColor (color) {
> set result [string match *$color* [getMem Document ChannelNames]]
> return $result
> }
>
> ------------ OR -----------------
Proc MatchColor (color) {
return [string match *$color* [getMem Document ChannelNames]]
}
---------------- OR ----------------------
Change all your MatchColor calls to something like
set ColorMatched [string match *$color* [getMem Document ChannelNames]]
More information about the Discuss
mailing list