home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / tcl / 2216 < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.2 KB  |  42 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!eco.twg.com!twg.com!news
  3. From: "David Herron" <david@twg.com>
  4. Subject: Re: trapping null selections from a listbox
  5. Message-ID: <1992Dec22.175335.4089@twg.com>
  6. Sensitivity: Personal
  7. Encoding:  22 TEXT , 4 TEXT 
  8. Sender: news@twg.com (USENET News System)
  9. Conversion: Prohibited
  10. Organization: The Wollongong Group, Inc., Palo Alto, CA
  11. Conversion-With-Loss: Prohibited
  12. Date: Tue, 22 Dec 1992 17:53:34 GMT
  13. Lines: 27
  14.  
  15. > I need to know how I can trap a null selection from a listbox.  This is
  16. > important in the app that I am building, as there is no default.  If the
  17. > user doesn't make a selection from the list box, then I need to know so I 
  18. > can flag the user with a dialog box.
  19.  
  20. If there's no selection then
  21.  
  22.     $top.l curselection
  23.  
  24. will return an empty list.  So what's the problem?
  25.  
  26. My idiom for this is:
  27.  
  28.     set sel [$top.l curselection]
  29.     if {$sel == ""} {
  30.         error "bitch about something.  automagically `return's
  31.             and uses tkerror{} to present the complaint."
  32.     }
  33.  
  34.     foreach s $sel {
  35.         ...process...
  36.     }
  37.  
  38. <- David Herron <david@twg.com> (work) <david@davids.mmdf.com> (home)
  39. <-
  40. <- During the '80s Usenet's mantra was: "Not all the world's a VAX".
  41. <- During the '90s I hope it becomes:   "Not all the world's DOS (ick)".
  42.