home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / tcl / 1786 < prev    next >
Encoding:
Text File  |  1992-11-10  |  1.9 KB  |  59 lines

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!think.com!ames!tulane!cpu.com!cpu.com!GWLESTER
  3. From: gwlester@cpu.com (Gerald W. Lester)
  4. Subject: Re: new user questions
  5. Nntp-Posting-Host: captainhook.cpu.com
  6. References: <1992Nov10.133434.26583@unilabs.uucp>
  7. Sender: usenet@cpu.com (Usenet administrator)
  8. Organization: Computerized Processes Unlimited, Metairie, LA, (504)-889-2784
  9. Date: Tue, 10 Nov 1992 18:39:33 GMT
  10. Message-ID: <1992Nov10.183933.10159@cpu.com>
  11. Reply-To: gwlester@cpu.com
  12. Lines: 45
  13.  
  14. In article <1992Nov10.133434.26583@unilabs.uucp>, chare@unilabs.uucp (Chris Hare) writes:
  15. >Tcl6.4
  16. >Tk2.3
  17. >SCO UNIX 3.2v4
  18. >
  19. >Well, I'm missing something somewhere.  Consider this code extract:
  20. >
  21. >catch { set fd [ open "$CategoryList" "r" ] } ok
  22. >puts stdout "fd = $fd"
  23. >set end { eof fd }
  24. >puts stdout "eof = $end"
  25. >while { $end == 0 } {
  26. >   set record { gets $fd }
  27. >   puts stdout "have $record"
  28. >   #
  29. >   # define the list
  30. >   #
  31. >   .left.list insert end $record
  32. >   set end { eof $fd }
  33. >puts stdout "eof = $end"
  34. >}
  35. >
  36. >What I want to acheive is to fill a list box with the contents of a file.
  37. >The open and catch work OK (although I want to add code to test for failure
  38. >and show a dialog box ), but the problem specifically is with the call to
  39. >eof.  The puts after the call to eof says the variable end contains the
  40. >text "eof fd".  How do I do this properly?
  41.  
  42.     set end [eof $fd]
  43. >
  44. >In addition, is there a tcl command like split it perl?  I have in anotehr
  45. >file which will be processed the text for the list box, and then a keyword
  46. >which specifies the name of the file which is to be opened.  This
  47. >information separated by colons.
  48.  
  49.     split string ":"
  50. or if your string is in the variable foobar
  51.     split $foobar ":"
  52.  
  53. >
  54. >Thanks!
  55. >-- 
  56. >????                --- It Always works for me! ---                           
  57. >Chris Hare, UNIX Scientist                  Preferred : chare@unilabs.org
  58. >Just a mild-mannered consultant by day ....
  59.