| 1 |
'\" |
| 2 |
'\" Copyright (c) 1994-1997 Sun Microsystems, Inc. |
| 3 |
'\" |
| 4 |
'\" See the file "license.terms" for information on usage and redistribution |
| 5 |
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 6 |
'\" |
| 7 |
.TH Tcl_WrongNumArgs 3 8.0 Tcl "Tcl Library Procedures" |
| 8 |
.so man.macros |
| 9 |
.BS |
| 10 |
.SH NAME |
| 11 |
Tcl_WrongNumArgs \- generate standard error message for wrong number of arguments |
| 12 |
.SH SYNOPSIS |
| 13 |
.nf |
| 14 |
\fB#include <tcl.h>\fR |
| 15 |
.sp |
| 16 |
\fBTcl_WrongNumArgs\fR(\fIinterp, objc, objv, message\fR) |
| 17 |
.SH ARGUMENTS |
| 18 |
.AS "Tcl_Obj *const" *message |
| 19 |
.AP Tcl_Interp interp in |
| 20 |
Interpreter in which error will be reported: error message gets stored |
| 21 |
in its result value. |
| 22 |
.AP int objc in |
| 23 |
Number of leading arguments from \fIobjv\fR to include in error |
| 24 |
message. |
| 25 |
.AP "Tcl_Obj *const" objv[] in |
| 26 |
Arguments to command that had the wrong number of arguments. |
| 27 |
.AP "const char" *message in |
| 28 |
Additional error information to print after leading arguments |
| 29 |
from \fIobjv\fR. This typically gives the acceptable syntax |
| 30 |
of the command. This argument may be NULL. |
| 31 |
.BE |
| 32 |
.SH DESCRIPTION |
| 33 |
.PP |
| 34 |
\fBTcl_WrongNumArgs\fR is a utility procedure that is invoked by |
| 35 |
command procedures when they discover that they have received the |
| 36 |
wrong number of arguments. \fBTcl_WrongNumArgs\fR generates a |
| 37 |
standard error message and stores it in the result value of |
| 38 |
\fIinterp\fR. The message includes the \fIobjc\fR initial |
| 39 |
elements of \fIobjv\fR plus \fImessage\fR. For example, if |
| 40 |
\fIobjv\fR consists of the values \fBfoo\fR and \fBbar\fR, |
| 41 |
\fIobjc\fR is 1, and \fImessage\fR is |
| 42 |
.QW "\fBfileName count\fR" |
| 43 |
then \fIinterp\fR's result value will be set to the following |
| 44 |
string: |
| 45 |
.PP |
| 46 |
.CS |
| 47 |
wrong # args: should be "foo fileName count" |
| 48 |
.CE |
| 49 |
.PP |
| 50 |
If \fIobjc\fR is 2, the result will be set to the following string: |
| 51 |
.PP |
| 52 |
.CS |
| 53 |
wrong # args: should be "foo bar fileName count" |
| 54 |
.CE |
| 55 |
.PP |
| 56 |
\fIObjc\fR is usually 1, but may be 2 or more for commands like |
| 57 |
\fBstring\fR and the Tk widget commands, which use the first argument |
| 58 |
as a subcommand. |
| 59 |
.PP |
| 60 |
Some of the values in the \fIobjv\fR array may be abbreviations for |
| 61 |
a subcommand. The command |
| 62 |
\fBTcl_GetIndexFromObj\fR will convert the abbreviated string value |
| 63 |
into an \fIindexObject\fR. If an error occurs in the parsing of the |
| 64 |
subcommand we would like to use the full subcommand name rather than |
| 65 |
the abbreviation. If the \fBTcl_WrongNumArgs\fR command finds any |
| 66 |
\fIindexObjects\fR in the \fIobjv\fR array it will use the full subcommand |
| 67 |
name in the error message instead of the abbreviated name that was |
| 68 |
originally passed in. Using the above example, let us assume that |
| 69 |
\fIbar\fR is actually an abbreviation for \fIbarfly\fR and the value |
| 70 |
is now an \fIindexObject\fR because it was passed to |
| 71 |
\fBTcl_GetIndexFromObj\fR. In this case the error message would be: |
| 72 |
.PP |
| 73 |
.CS |
| 74 |
wrong # args: should be "foo barfly fileName count" |
| 75 |
.CE |
| 76 |
.SH "SEE ALSO" |
| 77 |
Tcl_GetIndexFromObj(3) |
| 78 |
.SH KEYWORDS |
| 79 |
command, error message, wrong number of arguments |