home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.tcl
- Path: sparky!uunet!eco.twg.com!twg.com!news
- From: "David Herron" <david@twg.com>
- Subject: Re: trapping null selections from a listbox
- Message-ID: <1992Dec22.175335.4089@twg.com>
- Sensitivity: Personal
- Encoding: 22 TEXT , 4 TEXT
- Sender: news@twg.com (USENET News System)
- Conversion: Prohibited
- Organization: The Wollongong Group, Inc., Palo Alto, CA
- Conversion-With-Loss: Prohibited
- Date: Tue, 22 Dec 1992 17:53:34 GMT
- Lines: 27
-
- > I need to know how I can trap a null selection from a listbox. This is
- > important in the app that I am building, as there is no default. If the
- > user doesn't make a selection from the list box, then I need to know so I
- > can flag the user with a dialog box.
-
- If there's no selection then
-
- $top.l curselection
-
- will return an empty list. So what's the problem?
-
- My idiom for this is:
-
- set sel [$top.l curselection]
- if {$sel == ""} {
- error "bitch about something. automagically `return's
- and uses tkerror{} to present the complaint."
- }
-
- foreach s $sel {
- ...process...
- }
-
- <- David Herron <david@twg.com> (work) <david@davids.mmdf.com> (home)
- <-
- <- During the '80s Usenet's mantra was: "Not all the world's a VAX".
- <- During the '90s I hope it becomes: "Not all the world's DOS (ick)".
-