other versions
- wheezy 8.4.19-5
conflicting packages
Tcl_CreateCommand(3tcl) | Tcl Library Procedures | Tcl_CreateCommand(3tcl) |
NAME¶
Tcl_CreateCommand - implement new commands in CSYNOPSIS¶
#include <tcl.h>Tcl_Command Tcl_CreateCommand(interp, cmdName, proc, clientData, deleteProc)
ARGUMENTS¶
- Tcl_Interp *interp (in)
- Interpreter in which to create new command.
- CONST char *cmdName (in)
- Name of command.
- Tcl_CmdProc *proc (in)
- Implementation of new command: proc will be called whenever cmdName is invoked as a command.
- ClientData clientData (in)
- Arbitrary one-word value to pass to proc and deleteProc.
- Tcl_CmdDeleteProc *deleteProc (in)
- Procedure to call before cmdName is deleted from the
interpreter; allows for command-specific cleanup. If NULL, then no
procedure is called before the command is deleted.
DESCRIPTION¶
Tcl_CreateCommand defines a new command in interp and associates it with procedure proc such that whenever cmdName is invoked as a Tcl command (via a call to Tcl_Eval) the Tcl interpreter will call proc to process the command. It differs from Tcl_CreateObjCommand in that a new string-based command is defined; that is, a command procedure is defined that takes an array of argument strings instead of objects. The object-based command procedures registered by Tcl_CreateObjCommand can execute significantly faster than the string-based command procedures defined by Tcl_CreateCommand. This is because they take Tcl objects as arguments and those objects can retain an internal representation that can be manipulated more efficiently. Also, Tcl's interpreter now uses objects internally. In order to invoke a string-based command procedure registered by Tcl_CreateCommand, it must generate and fetch a string representation from each argument object before the call and create a new Tcl object to hold the string result returned by the string-based command procedure. New commands should be defined using Tcl_CreateObjCommand. We support Tcl_CreateCommand for backwards compatibility. The procedures Tcl_DeleteCommand, Tcl_GetCommandInfo, and Tcl_SetCommandInfo are used in conjunction with Tcl_CreateCommand. Tcl_CreateCommand will delete an existing command cmdName, if one is already associated with the interpreter. It returns a token that may be used to refer to the command in subsequent calls to Tcl_GetCommandName. If cmdName contains any :: namespace qualifiers, then the command is added to the specified namespace; otherwise the command is added to the global namespace. If Tcl_CreateCommand is called for an interpreter that is in the process of being deleted, then it does not create a new command and it returns NULL. Proc should have arguments and result that match the type Tcl_CmdProc:typedef int Tcl_CmdProc( ClientData clientData, Tcl_Interp * interp, int argc, CONST char * argv[]);
typedef void Tcl_CmdDeleteProc(ClientData clientData);
SEE ALSO¶
Tcl_CreateObjCommand, Tcl_DeleteCommand, Tcl_GetCommandInfo, Tcl_SetCommandInfo, Tcl_GetCommandName, Tcl_SetObjResultKEYWORDS¶
bind, command, create, delete, interpreter, namespaceTcl |