OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / CELLLINUX64 / util / CELLLINUX64 / man / man3 / Tk_ParseArgv.3
1 '\"
2 '\" Copyright (c) 1990-1992 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\" 
8 '\" RCS: @(#) $Id: ParseArgv.3,v 1.3 2002/01/25 21:09:36 dgp Exp $
9 '\" 
10 '\" The definitions below are for supplemental macros used in Tcl/Tk
11 '\" manual entries.
12 '\"
13 '\" .AP type name in/out ?indent?
14 '\"     Start paragraph describing an argument to a library procedure.
15 '\"     type is type of argument (int, etc.), in/out is either "in", "out",
16 '\"     or "in/out" to describe whether procedure reads or modifies arg,
17 '\"     and indent is equivalent to second arg of .IP (shouldn't ever be
18 '\"     needed;  use .AS below instead)
19 '\"
20 '\" .AS ?type? ?name?
21 '\"     Give maximum sizes of arguments for setting tab stops.  Type and
22 '\"     name are examples of largest possible arguments that will be passed
23 '\"     to .AP later.  If args are omitted, default tab stops are used.
24 '\"
25 '\" .BS
26 '\"     Start box enclosure.  From here until next .BE, everything will be
27 '\"     enclosed in one large box.
28 '\"
29 '\" .BE
30 '\"     End of box enclosure.
31 '\"
32 '\" .CS
33 '\"     Begin code excerpt.
34 '\"
35 '\" .CE
36 '\"     End code excerpt.
37 '\"
38 '\" .VS ?version? ?br?
39 '\"     Begin vertical sidebar, for use in marking newly-changed parts
40 '\"     of man pages.  The first argument is ignored and used for recording
41 '\"     the version when the .VS was added, so that the sidebars can be
42 '\"     found and removed when they reach a certain age.  If another argument
43 '\"     is present, then a line break is forced before starting the sidebar.
44 '\"
45 '\" .VE
46 '\"     End of vertical sidebar.
47 '\"
48 '\" .DS
49 '\"     Begin an indented unfilled display.
50 '\"
51 '\" .DE
52 '\"     End of indented unfilled display.
53 '\"
54 '\" .SO
55 '\"     Start of list of standard options for a Tk widget.  The
56 '\"     options follow on successive lines, in four columns separated
57 '\"     by tabs.
58 '\"
59 '\" .SE
60 '\"     End of list of standard options for a Tk widget.
61 '\"
62 '\" .OP cmdName dbName dbClass
63 '\"     Start of description of a specific option.  cmdName gives the
64 '\"     option's name as specified in the class command, dbName gives
65 '\"     the option's name in the option database, and dbClass gives
66 '\"     the option's class in the option database.
67 '\"
68 '\" .UL arg1 arg2
69 '\"     Print arg1 underlined, then print arg2 normally.
70 '\"
71 '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $
72 '\"
73 '\"     # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
74 .if t .wh -1.3i ^B
75 .nr ^l \n(.l
76 .ad b
77 '\"     # Start an argument description
78 .de AP
79 .ie !"\\$4"" .TP \\$4
80 .el \{\
81 .   ie !"\\$2"" .TP \\n()Cu
82 .   el          .TP 15
83 .\}
84 .ta \\n()Au \\n()Bu
85 .ie !"\\$3"" \{\
86 \&\\$1  \\fI\\$2\\fP    (\\$3)
87 .\".b
88 .\}
89 .el \{\
90 .br
91 .ie !"\\$2"" \{\
92 \&\\$1  \\fI\\$2\\fP
93 .\}
94 .el \{\
95 \&\\fI\\$1\\fP
96 .\}
97 .\}
98 ..
99 '\"     # define tabbing values for .AP
100 .de AS
101 .nr )A 10n
102 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
103 .nr )B \\n()Au+15n
104 .\"
105 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
106 .nr )C \\n()Bu+\\w'(in/out)'u+2n
107 ..
108 .AS Tcl_Interp Tcl_CreateInterp in/out
109 '\"     # BS - start boxed text
110 '\"     # ^y = starting y location
111 '\"     # ^b = 1
112 .de BS
113 .br
114 .mk ^y
115 .nr ^b 1u
116 .if n .nf
117 .if n .ti 0
118 .if n \l'\\n(.lu\(ul'
119 .if n .fi
120 ..
121 '\"     # BE - end boxed text (draw box now)
122 .de BE
123 .nf
124 .ti 0
125 .mk ^t
126 .ie n \l'\\n(^lu\(ul'
127 .el \{\
128 .\"     Draw four-sided box normally, but don't draw top of
129 .\"     box if the box started on an earlier page.
130 .ie !\\n(^b-1 \{\
131 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
132 .\}
133 .el \}\
134 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
135 .\}
136 .\}
137 .fi
138 .br
139 .nr ^b 0
140 ..
141 '\"     # VS - start vertical sidebar
142 '\"     # ^Y = starting y location
143 '\"     # ^v = 1 (for troff;  for nroff this doesn't matter)
144 .de VS
145 .if !"\\$2"" .br
146 .mk ^Y
147 .ie n 'mc \s12\(br\s0
148 .el .nr ^v 1u
149 ..
150 '\"     # VE - end of vertical sidebar
151 .de VE
152 .ie n 'mc
153 .el \{\
154 .ev 2
155 .nf
156 .ti 0
157 .mk ^t
158 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159 .sp -1
160 .fi
161 .ev
162 .\}
163 .nr ^v 0
164 ..
165 '\"     # Special macro to handle page bottom:  finish off current
166 '\"     # box/sidebar if in box/sidebar mode, then invoked standard
167 '\"     # page bottom macro.
168 .de ^B
169 .ev 2
170 'ti 0
171 'nf
172 .mk ^t
173 .if \\n(^b \{\
174 .\"     Draw three-sided box if this is the box's first page,
175 .\"     draw two sides but no top otherwise.
176 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
177 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
178 .\}
179 .if \\n(^v \{\
180 .nr ^x \\n(^tu+1v-\\n(^Yu
181 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
182 .\}
183 .bp
184 'fi
185 .ev
186 .if \\n(^b \{\
187 .mk ^y
188 .nr ^b 2
189 .\}
190 .if \\n(^v \{\
191 .mk ^Y
192 .\}
193 ..
194 '\"     # DS - begin display
195 .de DS
196 .RS
197 .nf
198 .sp
199 ..
200 '\"     # DE - end display
201 .de DE
202 .fi
203 .RE
204 .sp
205 ..
206 '\"     # SO - start of list of standard options
207 .de SO
208 .SH "STANDARD OPTIONS"
209 .LP
210 .nf
211 .ta 5.5c 11c
212 .ft B
213 ..
214 '\"     # SE - end of list of standard options
215 .de SE
216 .fi
217 .ft R
218 .LP
219 See the \\fBoptions\\fR manual entry for details on the standard options.
220 ..
221 '\"     # OP - start of full description for a single option
222 .de OP
223 .LP
224 .nf
225 .ta 4c
226 Command-Line Name:      \\fB\\$1\\fR
227 Database Name:  \\fB\\$2\\fR
228 Database Class: \\fB\\$3\\fR
229 .fi
230 .IP
231 ..
232 '\"     # CS - begin code excerpt
233 .de CS
234 .RS
235 .nf
236 .ta .25i .5i .75i 1i
237 ..
238 '\"     # CE - end code excerpt
239 .de CE
240 .fi
241 .RE
242 ..
243 .de UL
244 \\$1\l'|0\(ul'\\$2
245 ..
246 .TH Tk_ParseArgv 3 "" Tk "Tk Library Procedures"
247 .BS
248 .SH NAME
249 Tk_ParseArgv \- process command-line options
250 .SH SYNOPSIS
251 .nf
252 \fB#include <tk.h>\fR
253 .sp
254 int
255 \fBTk_ParseArgv\fR(\fIinterp, tkwin, argcPtr, argv, argTable, flags\fR)
256 .SH ARGUMENTS
257 .AS Tk_ArgvInfo *argTable
258 .AP Tcl_Interp *interp in
259 Interpreter to use for returning error messages.
260 .AP Tk_Window tkwin in
261 Window to use when arguments specify Tk options.  If NULL, then
262 no Tk options will be processed.
263 .AP int argcPtr in/out
264 Pointer to number of arguments in argv;  gets modified to hold
265 number of unprocessed arguments that remain after the call.
266 .AP "CONST char" **argv in/out
267 Command line arguments passed to main program.  Modified to
268 hold unprocessed arguments that remain after the call.
269 .AP Tk_ArgvInfo *argTable in
270 Array of argument descriptors, terminated by element with
271 type TK_ARGV_END.
272 .AP int flags in
273 If non-zero, then it specifies one or more flags that control the
274 parsing of arguments.  Different flags may be OR'ed together.
275 The flags currently defined are TK_ARGV_DONT_SKIP_FIRST_ARG,
276 TK_ARGV_NO_ABBREV, TK_ARGV_NO_LEFTOVERS, and TK_ARGV_NO_DEFAULTS.
277 .BE
278 .SH DESCRIPTION
279 .PP
280 \fBTk_ParseArgv\fR processes an array of command-line arguments according
281 to a table describing the kinds of arguments that are expected.
282 Each of the arguments in \fIargv\fR is processed in turn:  if it matches
283 one of the entries in \fIargTable\fR, the argument is processed
284 according to that entry and discarded.  The arguments that do not
285 match anything in \fIargTable\fR are copied down to the beginning
286 of \fIargv\fR (retaining their original order) and returned to
287 the caller.  At the end of the call
288 \fBTk_ParseArgv\fR sets \fI*argcPtr\fR to hold the number of
289 arguments that are left in \fIargv\fR, and \fIargv[*argcPtr]\fR
290 will hold the value NULL.  Normally, \fBTk_ParseArgv\fR
291 assumes that \fIargv[0]\fR is a command name, so it is treated like
292 an argument that doesn't match \fIargTable\fR and returned to the
293 caller;  however, if the TK_ARGV_DONT_SKIP_FIRST_ARG bit is set in
294 \fIflags\fR then \fIargv[0]\fR will be processed just like the other
295 elements of \fIargv\fR.
296 .PP
297 \fBTk_ParseArgv\fR normally returns the value TCL_OK.  If an error
298 occurs while parsing the arguments, then TCL_ERROR is returned and
299 \fBTk_ParseArgv\fR will leave an error message in \fIinterp->result\fR
300 in the standard Tcl fashion.  In
301 the event of an error return, \fI*argvPtr\fR will not have been
302 modified, but \fIargv\fR could have been partially modified.  The
303 possible causes of errors are explained below.
304 .PP
305 The \fIargTable\fR array specifies the kinds of arguments that are
306 expected;  each of its entries has the following structure:
307 .CS
308 typedef struct {
309         char *\fIkey\fR;
310         int \fItype\fR;
311         char *\fIsrc\fR;
312         char *\fIdst\fR;
313         char *\fIhelp\fR;
314 } Tk_ArgvInfo;
315 .CE
316 The \fIkey\fR field is a string such as ``\-display'' or ``\-bg''
317 that is compared with the values in \fIargv\fR.  \fIType\fR
318 indicates how to process an argument that matches \fIkey\fR
319 (more on this below).  \fISrc\fR and \fIdst\fR are additional
320 values used in processing the argument.  Their exact usage
321 depends on \fItype\fR, but typically \fIsrc\fR indicates
322 a value and \fIdst\fR indicates where to store the
323 value.  The \fBchar *\fR declarations for \fIsrc\fR and \fIdst\fR
324 are placeholders:  the actual types may be different.  Lastly,
325 \fIhelp\fR is a string giving a brief description
326 of this option;  this string is printed when users ask for help
327 about command-line options.
328 .PP
329 When processing an argument in \fIargv\fR, \fBTk_ParseArgv\fR
330 compares the argument to each of the \fIkey\fR's in \fIargTable\fR.
331 \fBTk_ParseArgv\fR selects the first specifier whose \fIkey\fR matches
332 the argument exactly, if such a specifier exists.  Otherwise
333 \fBTk_ParseArgv\fR selects a specifier for which the argument
334 is a unique abbreviation.  If the argument is a unique abbreviation
335 for more than one specifier, then an error is returned.  If there
336 is no matching entry in \fIargTable\fR, then the argument is
337 skipped and returned to the caller.
338 .PP
339 Once a matching argument specifier is found, \fBTk_ParseArgv\fR
340 processes the argument according to the \fItype\fR field of the
341 specifier.  The argument that matched \fIkey\fR is called ``the matching
342 argument'' in the descriptions below.  As part of the processing,
343 \fBTk_ParseArgv\fR may also use the next argument in \fIargv\fR
344 after the matching argument, which is called ``the following
345 argument''.  The legal values for \fItype\fR, and the processing
346 that they cause, are as follows:
347 .TP
348 \fBTK_ARGV_END\fR
349 Marks the end of the table.  The last entry in \fIargTable\fR
350 must have this type;  all of its other fields are ignored and it
351 will never match any arguments.
352 .TP
353 \fBTK_ARGV_CONSTANT\fR
354 \fISrc\fR is treated as an integer and \fIdst\fR is treated
355 as a pointer to an integer.  \fISrc\fR is stored at \fI*dst\fR.
356 The matching argument is discarded.
357 .TP
358 \fBTK_ARGV_INT\fR
359 The following argument must contain an
360 integer string in the format accepted by \fBstrtol\fR (e.g. ``0''
361 and ``0x'' prefixes may be used to specify octal or hexadecimal
362 numbers, respectively).  \fIDst\fR is treated as a pointer to an
363 integer;  the following argument is converted to an integer value
364 and stored at \fI*dst\fR.  \fISrc\fR is ignored.  The matching
365 and following arguments are discarded from \fIargv\fR.
366 .TP
367 \fBTK_ARGV_FLOAT\fR
368 The following argument must contain a floating-point number in
369 the format accepted by \fBstrtol\fR.
370 \fIDst\fR is treated as the address of an double-precision
371 floating point value;  the following argument is converted to a
372 double-precision value and stored at \fI*dst\fR.  The matching
373 and following arguments are discarded from \fIargv\fR.
374 .TP
375 \fBTK_ARGV_STRING\fR
376 In this form, \fIdst\fR is treated as a pointer to a (char *);
377 \fBTk_ParseArgv\fR stores at \fI*dst\fR a pointer to the following
378 argument, and discards the matching and following arguments from
379 \fIargv\fR.  \fISrc\fR is ignored.
380 .TP
381 \fBTK_ARGV_UID\fR
382 This form is similar to TK_ARGV_STRING, except that the argument
383 is turned into a Tk_Uid by calling \fBTk_GetUid\fR.
384 \fIDst\fR is treated as a pointer to a
385 Tk_Uid; \fBTk_ParseArgv\fR stores at \fI*dst\fR the Tk_Uid
386 corresponding to the following
387 argument, and discards the matching and following arguments from
388 \fIargv\fR.  \fISrc\fR is ignored.
389 .TP
390 \fBTK_ARGV_CONST_OPTION\fR
391 This form causes a Tk option to be set (as if the \fBoption\fR
392 command had been invoked).  The \fIsrc\fR field is treated as a
393 pointer to a string giving the value of an option, and \fIdst\fR
394 is treated as a pointer to the name of the option.  The matching
395 argument is discarded.  If \fItkwin\fR is NULL, then argument
396 specifiers of this type are ignored (as if they did not exist).
397 .TP
398 \fBTK_ARGV_OPTION_VALUE\fR
399 This form is similar to TK_ARGV_CONST_OPTION, except that the
400 value of the option is taken from the following argument instead
401 of from \fIsrc\fR.  \fIDst\fR is used as the name of the option.
402 \fISrc\fR is ignored.  The matching and following arguments
403 are discarded.  If \fItkwin\fR is NULL, then argument
404 specifiers of this type are ignored (as if they did not exist).
405 .TP
406 \fBTK_ARGV_OPTION_NAME_VALUE\fR
407 In this case the following argument is taken as the name of a Tk
408 option and the argument after that is taken as the value for that
409 option.  Both \fIsrc\fR and \fIdst\fR are ignored.  All three
410 arguments are discarded from \fIargv\fR.  If \fItkwin\fR is NULL,
411 then argument
412 specifiers of this type are ignored (as if they did not exist).
413 .TP
414 \fBTK_ARGV_HELP\fR
415 When this kind of option is encountered, \fBTk_ParseArgv\fR uses the
416 \fIhelp\fR fields of \fIargTable\fR to format a message describing
417 all the valid arguments.  The message is placed in \fIinterp->result\fR
418 and \fBTk_ParseArgv\fR returns TCL_ERROR.  When this happens, the
419 caller normally prints the help message and aborts.  If the \fIkey\fR
420 field of a TK_ARGV_HELP specifier is NULL, then the specifier will
421 never match any arguments;  in this case the specifier simply provides
422 extra documentation, which will be included when some other
423 TK_ARGV_HELP entry causes help information to be returned.
424 .TP
425 \fBTK_ARGV_REST\fR
426 This option is used by programs or commands that allow the last
427 several of their options to be the name and/or options for some
428 other program.  If a \fBTK_ARGV_REST\fR argument is found, then
429 \fBTk_ParseArgv\fR doesn't process any
430 of the remaining arguments;  it returns them all at
431 the beginning of \fIargv\fR (along with any other unprocessed arguments).
432 In addition, \fBTk_ParseArgv\fR treats \fIdst\fR as the address of an
433 integer value, and stores at \fI*dst\fR the index of the first of the
434 \fBTK_ARGV_REST\fR options in the returned \fIargv\fR.  This allows the
435 program to distinguish the \fBTK_ARGV_REST\fR options from other
436 unprocessed options that preceded the \fBTK_ARGV_REST\fR.
437 .TP
438 \fBTK_ARGV_FUNC\fR
439 For this kind of argument, \fIsrc\fR is treated as the address of
440 a procedure, which is invoked to process the following argument.
441 The procedure should have the following structure:
442 .RS
443 .CS
444 int
445 \fIfunc\fR(\fIdst\fR, \fIkey\fR, \fInextArg\fR)
446         char *\fIdst\fR;
447         char *\fIkey\fR;
448         char *\fInextArg\fR;
449 {
450 }
451 .CE
452 The \fIdst\fR and \fIkey\fR parameters will contain the
453 corresponding fields from the \fIargTable\fR entry, and
454 \fInextArg\fR will point to the following argument from \fIargv\fR
455 (or NULL if there aren't any more arguments left in \fIargv\fR).
456 If \fIfunc\fR uses \fInextArg\fR (so that
457 \fBTk_ParseArgv\fR should discard it), then it should return 1.  Otherwise it
458 should return 0 and \fBTkParseArgv\fR will process the following
459 argument in the normal fashion.  In either event the matching argument
460 is discarded.
461 .RE
462 .TP
463 \fBTK_ARGV_GENFUNC\fR
464 This form provides a more general procedural escape.  It treats
465 \fIsrc\fR as the address of a procedure, and passes that procedure
466 all of the remaining arguments.  The procedure should have the following
467 form:
468 .RS
469 .CS
470 int
471 \fIgenfunc\fR(dst, interp, key, argc, argv)
472         char *\fIdst\fR;
473         Tcl_Interp *\fIinterp\fR;
474         char *\fIkey\fR;
475         int \fIargc\fR;
476         char **\fIargv\fR;
477 {
478 }
479 .CE
480 The \fIdst\fR and \fIkey\fR parameters will contain the
481 corresponding fields from the \fIargTable\fR entry.  \fIInterp\fR
482 will be the same as the \fIinterp\fR argument to \fBTcl_ParseArgv\fR.
483 \fIArgc\fR and \fIargv\fR refer to all of the options after the
484 matching one.  \fIGenfunc\fR should behave in a fashion similar
485 to \fBTk_ParseArgv\fR:  parse as many of the remaining arguments as it can,
486 then return any that are left by compacting them to the beginning of
487 \fIargv\fR (starting at \fIargv\fR[0]).  \fIGenfunc\fR
488 should return a count of how many arguments are left in \fIargv\fR;
489 \fBTk_ParseArgv\fR will process them.  If \fIgenfunc\fR encounters
490 an error then it should leave an error message in \fIinterp->result\fR,
491 in the usual Tcl fashion, and return -1;  when this happens
492 \fBTk_ParseArgv\fR will abort its processing and return TCL_ERROR.
493 .RE
494
495 .SH "FLAGS"
496 .TP
497 \fBTK_ARGV_DONT_SKIP_FIRST_ARG\fR
498 \fBTk_ParseArgv\fR normally treats \fIargv[0]\fR as a program
499 or command name, and returns it to the caller just as if it
500 hadn't matched \fIargTable\fR.  If this flag is given, then
501 \fIargv[0]\fR is not given special treatment.
502 .TP
503 \fBTK_ARGV_NO_ABBREV\fR
504 Normally, \fBTk_ParseArgv\fR accepts unique abbreviations for
505 \fIkey\fR values in \fIargTable\fR.  If this flag is given then
506 only exact matches will be acceptable.
507 .TP
508 \fBTK_ARGV_NO_LEFTOVERS\fR
509 Normally, \fBTk_ParseArgv\fR returns unrecognized arguments to the
510 caller.  If this bit is set in \fIflags\fR then \fBTk_ParseArgv\fR
511 will return an error if it encounters any argument that doesn't
512 match \fIargTable\fR.  The only exception to this rule is \fIargv[0]\fR,
513 which will be returned to the caller with no errors as
514 long as TK_ARGV_DONT_SKIP_FIRST_ARG isn't specified.
515 .TP
516 \fBTK_ARGV_NO_DEFAULTS\fR
517 Normally, \fBTk_ParseArgv\fR searches an internal table of
518 standard argument specifiers in addition to \fIargTable\fR.  If
519 this bit is set in \fIflags\fR, then \fBTk_ParseArgv\fR will
520 use only \fIargTable\fR and not its default table.
521
522 .SH EXAMPLE
523 .PP
524 Here is an example definition of an \fIargTable\fR and
525 some sample command lines that use the options.  Note the effect
526 on \fIargc\fR and \fIargv\fR;  arguments processed by \fBTk_ParseArgv\fR
527 are eliminated from \fIargv\fR, and \fIargc\fR
528 is updated to reflect reduced number of arguments.
529 .CS
530 /*
531  * Define and set default values for globals.
532  */
533 int debugFlag = 0;
534 int numReps = 100;
535 char defaultFileName[] = "out";
536 char *fileName = defaultFileName;
537 Boolean exec = FALSE;
538
539 /*
540  * Define option descriptions.
541  */
542 Tk_ArgvInfo argTable[] = {
543         {"-X", TK_ARGV_CONSTANT, (char *) 1, (char *) &debugFlag,
544                 "Turn on debugging printfs"},
545         {"-N", TK_ARGV_INT, (char *) NULL, (char *) &numReps,
546                 "Number of repetitions"},
547         {"-of", TK_ARGV_STRING, (char *) NULL, (char *) &fileName,
548                 "Name of file for output"},
549         {"x", TK_ARGV_REST, (char *) NULL, (char *) &exec,
550                 "File to exec, followed by any arguments (must be last argument)."},
551         {(char *) NULL, TK_ARGV_END, (char *) NULL, (char *) NULL,
552             (char *) NULL}
553 };
554
555 main(argc, argv)
556         int argc;
557         char *argv[];
558 {
559         \&...
560
561         if (Tk_ParseArgv(interp, tkwin, &argc, argv, argTable, 0) != TCL_OK) {
562                 fprintf(stderr, "%s\en", interp->result);
563                 exit(1);
564         }
565
566         /*
567          * Remainder of the program.
568          */
569 }
570 .CE
571 .PP
572 Note that default values can be assigned to variables named in
573 \fIargTable\fR:  the variables will only be overwritten if the
574 particular arguments are present in \fIargv\fR.
575 Here are some example command lines and their effects.
576 .CS
577 prog -N 200 infile              # just sets the numReps variable to 200
578 prog -of out200 infile  # sets fileName to reference "out200"
579 prog -XN 10 infile              # sets the debug flag, also sets numReps
580 .CE
581 In all of the above examples, \fIargc\fR will be set by \fBTk_ParseArgv\fR to 2,
582 \fIargv\fR[0] will be ``prog'', \fIargv\fR[1] will be ``infile'',
583 and \fIargv\fR[2] will be NULL.
584
585 .SH KEYWORDS
586 arguments, command line, options