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

  1. Newsgroups: comp.lang.tcl
  2. Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!ghostwind!shmdgljd
  3. From: shmdgljd@rchland.vnet.ibm.com (Jay Schmidgall)
  4. Subject: Re: standard output from wish
  5. Sender: news@rchland.ibm.com
  6. Message-ID: <1992Nov10.185846.16970@rchland.ibm.com>
  7. Date: Tue, 10 Nov 1992 18:58:46 GMT
  8. Reply-To: jay@vnet.ibm.com
  9. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  10. References:  <1992Nov10.171427.6285@cs.cornell.edu>
  11. Nntp-Posting-Host: ghostwind.rchland.ibm.com
  12. Organization: IBM Rochester, MN
  13. Lines: 26
  14.  
  15. In article <1992Nov10.171427.6285@cs.cornell.edu>, davis@cs.cornell.edu (Jim Davis) writes:
  16. |> if ($#argv > 5) then
  17. |>   echo "usage: `basename $0`  FILE [-switch baz] "
  18. |>   exit 1
  19. |> endif
  20. |> What's the Tcl/wish equivalent?
  21.  
  22. Unfortunately, wish hides what would be argv[0] from you, so I don't
  23. know any nifty way to get your script name other than hardcoding it.
  24.  
  25. Granting that, you could do
  26.  
  27.    set programName {foo}
  28.    if {[set argc [llength $argv]] > 5} {
  29.        puts stderr [format {usage: %s FILE [-switch baz]} $programName]
  30.        exit 1
  31.    }
  32.    puts stdout "argv is ($argv), argc is $argc"
  33.    exit 0
  34.  
  35. If you're using wish built with extended tcl, programName will be set for
  36. you, I believe.
  37.  
  38. -- 
  39. : jay          jay@vnet.ibm.com    My opinions and ideas, not my employer's.
  40. : shmdgljd@rchland.vnet.ibm.com    (c) Copyright 1992.  All rights reserved.
  41.