home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / incoming / jstools-.6v3 / jstools- / jstools-tk3.6v3.0 / lib / jdoc / jparseargs.tcl.jdoc < prev    next >
Encoding:
Text File  |  1995-03-14  |  7.0 KB  |  85 lines

  1. {jparseargs.tcl
  2.  
  3. Introduction
  4. The jparseargs.tcl library is distributed as part of the jstools package.  It consists of procedures to procedure and application arguments in the typical Tcl `-option value' format.
  5.  
  6. This document describes jparseargs.tcl version 3.6/3.0.
  7.  
  8. Usage
  9. Accessing the Library
  10. In order to use the jparseargs.tcl library, it (and any other libraries it depends on) must be in your Tcl auto_path, described in tclvars(n).  Information about how to arrange that, and other conventions common to the jstools libraries, is in the Usage section of The jstools Libraries.
  11.  
  12. Credits and Copyright
  13. Author
  14. Jay Sekora 
  15. js@bu.edu
  16. http://shore.net/~js/
  17.  
  18. Copyright
  19. The library is copyright ⌐ 1992-1994 by Jay Sekora, but may be freely copied and modified for non¡commercial purposes.  (Please contact me if you want to use it for a commercial purpose, this may be OK under some circumstances.)
  20.  
  21. Overview
  22. Procedures
  23. j:parse_args - parse option list in parent procedure
  24. j:parse_argv - parse argv variable (options to script)
  25.  
  26. j:parse_args
  27. Usage
  28.     proc procname { args } {
  29.       j:parse_args arglist
  30.     ...}
  31. Argument
  32.     arglist - list of {option default} pairs
  33. Example
  34.     proc alert { args } {
  35.       j:parse_args {
  36.         {title "Alert"}
  37.         {text "Alert!"}
  38.         {ok "OK"}
  39.       }
  40.       toplevel .foo
  41.       wm title .foo $title
  42.       message .foo.msg -text $text
  43.       button .foo.btn -text $ok -command {destroy .foo}
  44.       pack .foo.msg .foo.btn
  45.     }
  46.  
  47. Description
  48. This procedure is used by almost all the other procedures in jlibrary.tcl.  It extracts options from the variable args in the parent procedure, and sets corresponding variables, also in the parent procedure.  (See the proc(1) manual page for an explanation of the args variable.)  Its argument is a list of {option default} sublists.  For each pair, the parent's args variable is scanned for elements matching option, preceded by a hyphen.  (For instance, if an option is `title', j:parse_args searches for `-title'.)  If a match is found, the following word is used as the value of that parameter, and a variable with the name option is set to that value in the parent procedure.  (To continue the example, the parent's variable title would be set to the element following `-title' in $args.)  If no match is found, the parent's option variable is set to the value of default.
  49.  
  50. Although not as flexible as getopt(3), this procedure makes it fairly easy to process lists of optional arguments.
  51.  
  52. j:parse_argv
  53. Usage
  54.     j:parse_args arglist
  55. Argument
  56.     arglist - list of {option default} pairs
  57. Example
  58.     j:parse_argv {
  59.       {font Courier10}
  60.       {headerfont Times-Bold12}
  61.       {columns 1}
  62.       {orient portrait}
  63.     }
  64.  
  65. Description
  66. This procedure is almost identical to j:parse_args, but instead of parsing the args variable in a procedure, it parses the global argv variable.  I.e., instead of parsing procedure arguments, it parses script arguments.
  67.  
  68. It removes any items it processes from argv, and sets argc to the length of argv when it's done.
  69.  
  70. For more information about the argv and argc variables, see the wish(1) or tclsh(1) manual page.
  71.  
  72. Evolution
  73. Feel free to report bugs (and feature requests) to me, <js@bu.edu>, and I will try to deal with them.  Also, feel free to fix bugs or add features on your own and let me know how you did it.
  74.  
  75. Changes Since Version 3.6/2.0
  76. * The j:parse_argv procedure is new.
  77.  
  78. Changes from Previous Versions
  79. * These procedures used to be in a file called jlibrary.tcl.  Starting with version 3.6/2.0, they're in their own independent library.
  80.  
  81. Future Directions
  82. * There should be a way to make aliases for existing options, in the same way that -bd is an alias for -borderwidth in Tk.
  83.  
  84. * There should be a way to specify boolean options which don't take an argument, but set a variable to 1 if they appear, and 0 otherwise.
  85. } {{{jdoc:xref:link {4.57 4.64 10.215 10.236 10.244 10.261 10.265 10.286 23.0 23.12 24.0 24.12 66.38 66.50}} {jdoc:xref:manpage {10.131 10.138 48.218 48.222 50.28 50.34 70.64 70.68 70.75 70.80}} {jdoc:anchor:anchorname {3.0 4.0 8.0 9.0 12.0 13.0 21.0 22.0 26.0 27.0 52.0 53.0 72.0 73.0}} {richtext:font:roman {2.0 3.0 4.0 4.4 4.18 4.57 4.64 4.160 4.173 6.24 6.38 8.0 10.0 10.20 10.34 10.107 10.116 10.131 10.138 10.219 10.226 10.248 10.253 10.265 10.286 12.0 14.0 15.0 15.9 16.0 16.21 18.0 19.0 21.0 23.12 24.0 24.12 24.21 24.25 26.0 32.0 32.1 32.8 32.19 32.35 33.0 46.0 47.0 48.0 48.61 48.73 48.114 48.118 48.218 48.222 48.264 48.268 48.307 48.323 48.363 48.367 48.410 48.416 48.462 48.468 48.473 48.478 48.481 48.493 48.508 48.514 48.628 48.634 48.730 48.735 48.775 48.781 48.786 48.791 48.830 48.836 48.869 48.876 50.28 50.34 52.0 56.0 56.1 56.8 56.19 56.35 57.0 64.0 65.0 66.0 66.38 66.50 66.79 66.83 66.130 66.134 68.39 68.43 68.54 68.58 68.76 68.80 70.31 70.35 70.40 70.44 70.64 70.68 70.75 70.80 72.0 73.0 73.55 73.66 75.0 76.0 76.6 76.18 78.0 78.30 79.47 79.59 81.0 81.17 82.83 82.86 82.103 82.115 84.103 84.104 84.125 84.126 85.0}} {richtext:font:italic {4.168 4.173 29.16 29.23 32.1 32.8 32.20 32.26 32.27 32.34 48.308 48.314 48.315 48.322 48.410 48.416 48.462 48.468 48.628 48.634 48.830 48.836 48.869 48.876 54.14 54.21 56.1 56.8 56.20 56.26 56.27 56.34}} {richtext:font:bold {4.4 4.18 4.57 4.64 6.24 6.38 10.20 10.34 10.219 10.226 48.61 48.73 79.47 79.59}} {richtext:font:bolditalic {10.248 10.253 10.265 10.286}} {richtext:font:typewriter {4.160 4.168 10.107 10.116 10.131 10.138 15.0 15.9 16.0 16.21 23.0 23.12 24.0 24.12 24.21 24.25 28.0 29.16 29.23 31.0 32.19 32.20 32.26 32.27 32.34 32.35 34.0 46.0 48.114 48.118 48.218 48.222 48.264 48.268 48.307 48.308 48.314 48.315 48.322 48.323 48.363 48.367 48.473 48.478 48.481 48.493 48.508 48.514 48.730 48.735 48.775 48.781 48.786 48.791 50.28 50.34 54.0 54.14 54.21 55.0 56.19 56.20 56.26 56.27 56.34 56.35 58.0 64.0 66.38 66.50 66.79 66.83 66.130 66.134 68.39 68.43 68.54 68.58 68.76 68.80 70.31 70.35 70.40 70.44 70.64 70.68 70.75 70.80 73.55 73.66 76.6 76.18 82.83 82.86 82.103 82.115 84.103 84.104 84.125 84.126}} {richtext:font:heading0 {1.0 2.0}} {richtext:font:heading1 {3.0 4.0 8.0 9.0 12.0 13.0 21.0 22.0 26.0 27.0 52.0 53.0 72.0 73.0}} {richtext:font:heading2 {9.0 10.0 13.0 14.0 18.0 19.0 22.0 23.0 27.0 28.0 31.0 32.0 33.0 34.0 47.0 48.0 53.0 54.0 55.0 56.0 57.0 58.0 65.0 66.0 75.0 76.0 78.0 78.30 81.0 81.17}} {jdoc:link:jstools.jdoc {4.57 4.64}} {jdoc:manpage:tclvars {10.131 10.138}} {jdoc:link:jslibraries.tcl {10.215 10.236}} {jdoc:link:jslibraries.jdoc#Usage {10.244 10.261}} {jdoc:link:jslibraries.jdoc {10.265 10.286}} {{} {12.0 20.0 22.0 22.10 80.0 81.0}} {jdoc:manpage:proc {48.218 48.222}} {jdoc:manpage:getopt {50.28 50.34}} {jdoc:anchorname:j:parse_args {26.0 27.0}} {jdoc:anchorname:Overview {21.0 22.0}} {jdoc:anchorname:Credits_and_Copyright {12.0 13.0}} {jdoc:anchorname:Usage {8.0 9.0}} {jdoc:anchorname:Introduction {3.0 4.0}} {jdoc:anchorname:j:parse_argv {52.0 53.0}} {jdoc:link:#j:parse_args {23.0 23.12 66.38 66.50}} {jdoc:link:#j:parse_argv {24.0 24.12}} {jdoc:manpage:tclsh {70.75 70.80}} {jdoc:manpage:wish {70.64 70.68}} {jdoc:anchorname:Evolution {72.0 73.0}}} {{abbrevstart 85.0} {richptr 85.0} {abbrevend 85.0} {insert 1.0} {anchor 1.0} {current 1.0}}}