SYNOPSIS
#include <tcl.h>
int Tcl_GetIndexFromObj(interp, objPtr, tablePtr, msg, flags, indexPtr)
int Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, indexPtr)
ARGUMENTS
- Tcl_Interp *interp (in)
-
Interpreter to use for error reporting; if NULL, then no message is provided on errors.
- Tcl_Obj *objPtr (in/out)
-
The string value of this object is used to search through tablePtr. The internal representation is modified to hold the index of the matching table entry.
- char **tablePtr (in)
-
An array of null-terminated strings. The end of the array is marked by a NULL string pointer.
- int offset (in)
-
The offset to add to tablePtr to get to the next string in the list. The end of the array is marked by a NULL string pointer.
- char *msg (in)
-
Null-terminated string describing what is being looked up, such as option. This string is included in error messages.
- int flags (in)
-
OR-ed combination of bits providing additional information for operation. The only bit that is currently defined is TCL_EXACT.
- int *indexPtr (out)
-
The index of the string in tablePtr that matches the value of objPtr is returned here.
DESCRIPTION
This procedure provides an efficient way for looking up keywords, switch names, option names, and similar things where the value of an object must be one of a predefined set of values. ObjPtr is compared against each of the strings in tablePtr to find a match. A match occurs if objPtr's string value is identical to one of the strings in tablePtr, or if it is a unique abbreviation for exactly one of the strings in tablePtr and the TCL_EXACT flag was not specified; in either case the index of the matching entry is stored at *indexPtr and TCL_OK is returned.
If there is no matching entry, TCL_ERROR is returned and an error message is left in interp's result if interp isn't NULL. Msg is included in the error message to indicate what was being looked up. For example, if msg is option the error message will have a form like bad option "firt": must be first, second, or third.
If
PORTABILITY
Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- Functions:
Tcl_WrongNumArgs()
PTC MKS Toolkit 10.4 Documentation Build 39.