NAME
TclGetAssocData, TclSetAssocData, TclDeleteAssocData - manage asso-
ciations of string keys and user specified data with Tcl interpreters.SYNOPSIS
##iinncclluuddee <
ClientData TTccllGGeettAAssssooccDDaattaa(interp, key, delProcPtr) TTccllSSeettAAssssooccDDaattaa(interp, key, delProc, clientData) TTccllDDeelleetteeAAssssooccDDaattaa(interp, key) AARRGGUUMMEENNTTSS TclInterp *interp (in) Interpreter in which to execute the specified command. | CONST | char *key (in) | | Key for association with which to store data or from which to delete or> retrieve data. Typi-
cally the module prefix for a package. TclInterpDeleteProc *delProc (in) Procedure to call when interp is deleted. TclInterpDeleteProc **delProcPtr (in) Pointer to location in which to store addressof current deletion pro-
cedure for association. Ignored if NULL.ClientData clientData (in) Arbitrary one-word value
associated with thegiven key in this inter-
preter. This data is owned by the caller.DESCRIPTION
These procedures allow extensions to associate their own data with a Tcl interpreter. An association consists of a string key, typicallythe name of the extension, and a one-word value, which is typically a
pointer to a data structure holding data specific to the extension.Tcl makes no interpretation of either the key or the value for an asso-
ciation. Storage management is facilitated by storing with each association a procedure to call when the interpreter is deleted. This procedure can dispose of the storage occupied by the client's data in any way it sees fit. TTccllSSeettAAssssooccDDaattaa creates an association between a string key and a userspecified datum in the given interpreter. If there is already an asso-
ciation with the given key, TTccllSSeettAAssssooccDDaattaa overwrites it with the new information. It is up to callers to organize their use of names to avoid conflicts, for example, by using package names as the keys. Ifthe deleteProc argument is non-NULL it specifies the address of a pro-
cedure to invoke if the interpreter is deleted before the association is deleted. DeleteProc should have arguments and result that match the type TTccllIInntteerrppDDeelleetteePPrroocc: typedef void TclInterpDeleteProc( ClientData clientData, TclInterp *interp); When deleteProc is invoked the clientData and interp arguments will be the same as the corresponding arguments passed to TTccllSSeettAAssssooccDDaattaa. The deletion procedure will not be invoked if the association is deleted before the interpreter is deleted. TTccllGGeettAAssssooccDDaattaa returns the datum stored in the association with the specified key in the given interpreter, and if the delProcPtr field isnon-NNUULLLL, the address indicated by it gets the address of the delete
procedure stored with this association. If no association with the specified key exists in the given interpreter TTccllGGeettAAssssooccDDaattaa returns NNUULLLL. TTccllDDeelleetteeAAssssooccDDaattaa deletes an association with a specified key in the given interpreter. Then it calls the deletion procedure. KKEEYYWWOORRDDSS association, data, deletion procedure, interpreter, key Tcl 7.5 TclSetAssocData(3)