Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<b>Sticky problem: Wrong number of argument</b>

Status
Not open for further replies.

fox5

Programmer
Feb 27, 2002
3
US
I have a function in .dll library:

int DATA(ClientData clientData, Tcl_Interp *interp,
int argc, char *argv[])
{
static char rtn[100];
if (argc != 3) {
Tcl_SetResult(interp, "wrong number of arguments ", TCL_STATIC);
return TCL_ERROR;
}
if ( srl_data(customerID,argv[1],argv[2]) ) {
if (srl_status(rtn)) {
Tcl_SetResult(interp, rtn, TCL_STATIC);
return TCL_ERROR;
}
}
Tcl_SetResult(interp, "Data ok", TCL_STATIC);
return TCL_OK;
}
}

"foo" is the namespace for the above function.

From my tcl script, I called the function like this:
if {[catch {::foo::DATA $custID $custName $custValue} ERR]} { puts "$ERR"
} else {
puts "The DATA call is successful"
}

Unfortunately, it returns the error message:
Wrong number of arguments.
I've been hanging on this problem for 2 days. Please help!!!



 
The argc/argv parameters passed to Tcl command functions include the command name as the first argument, just like the parameters to a C program's main() routine. So, you need to adjust your argument test to:

Code:
if (argc != 4) {

(Admittedly, this differs from the use of the argc/argv global variables exposed at the scripting layer (which contain the script command arguments). Those variables don't include the script name as the first argument; instead it's stored in a separate global variable argv0.)
- Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top