GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TCL_GETINDEXFROMOBJ (3)

NAME

Tcl_GetIndexFromObj, Tcl_GetIndexFromObjStruct - lookup string in table of keywords

CONTENTS

Synopsis
Arguments
Description
Keywords

SYNOPSIS

#include <tcl.h>

int Tcl_GetIndexFromObj(interp, objPtr, tablePtr, msg, flags, indexPtr)

int Tcl_GetIndexFromObjStruct(interp, objPtr, structTablePtr, offset, msg, flags, indexPtr)

ARGUMENTS


.TP 15 Tcl_Interp *interp (in)
Tcl_Interp*interp Tcl_Interp Interpreter to use for error reporting; if NULL, then no message is provided on errors.
.TP 15 Tcl_Obj *objPtr (in/out)
Tcl_Obj   *objPtr Tcl_Obj 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.
.TP 15 const char **tablePtr (in)
const char**tablePtr const char An array of null-terminated strings. The end of the array is marked by a NULL string pointer.
.TP 15 const void *structTablePtr (in)
const void*structTablePtr const void An array of arbitrary type, typically some struct type. The first member of the structure must be a null-terminated string. The size of the structure is given by offset.
.TP 15 int offset (in)
int       offset int The offset to add to structTablePtr to get to the next entry. The end of the array is marked by a NULL string pointer.
.TP 15 const char *msg (in)
const char*msg const char Null-terminated string describing what is being looked up, such as option. This string is included in error messages.
.TP 15 int flags (in)
int       flags int OR-ed combination of bits providing additional information for operation. The only bit that is currently defined is TCL_EXACT.
.TP 15 int *indexPtr (out)
int       *indexPtr int The index of the string in tablePtr that matches the value of objPtr is returned here.

   








\L’|0u-1v’\l’75u+3n_’\L’0u+1v-0u’\l’|0u-1.5n_’



\L’|0u-1v’\L’0u+1v-0u’\l’|0u-1.5n_’





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 non-empty 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 is not 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 \N’34’firt\N’34’: must be first, second, or third”.

If Tcl_GetIndexFromObj completes successfully it modifies the internal representation of objPtr to hold the address of the table and the index of the matching entry. If Tcl_GetIndexFromObj is invoked again with the same objPtr and tablePtr arguments (e.g. during a reinvocation of a Tcl command), it returns the matching index immediately without having to redo the lookup operation. Note: Tcl_GetIndexFromObj assumes that the entries in tablePtr are static: they must not change between invocations. If the value of objPtr is the empty string, Tcl_GetIndexFromObj will treat it as a non-matching value and return TCL_ERROR.

Tcl_GetIndexFromObjStruct works just like Tcl_GetIndexFromObj, except that instead of treating tablePtr as an array of string pointers, it treats it as a pointer to the first string in a series of strings that have offset bytes between them (i.e. that there is a pointer to the first array of characters at tablePtr, a pointer to the second array of characters at tablePtr+offset bytes, etc.) This is particularly useful when processing things like Tk_ConfigurationSpec, whose string keys are in the same place in each of several array elements.

SEE ALSO

Tcl_WrongNumArgs

KEYWORDS

index, object, table lookup
Search for    or go to Top of page |  Section 3 |  Main Index


Tcl TCL_GETINDEXFROMOBJ (3) 8.1

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.