⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objsetvar.3

📁 linux系统下的音频通信
💻 3
字号:
'\"'\" Copyright (c) 1996-1997 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" SCCS: @(#) ObjSetVar.3 1.6 97/05/19 17:35:44'\" .so man.macros.TH Tcl_ObjSetVar2 3 8.0 Tcl "Tcl Library Procedures".BS.SH NAMETcl_ObjSetVar2, Tcl_ObjGetVar2 \- manipulate Tcl variables.SH SYNOPSIS.nf\fB#include <tcl.h>\fR.spTcl_Obj *\fBTcl_ObjSetVar2\fR(\fIinterp, part1Ptr, part2Ptr, newValuePtr, flags\fR).spTcl_Obj *\fBTcl_ObjGetVar2\fR(\fIinterp, part1Ptr, part2Ptr, flags\fR).SH ARGUMENTS.AS Tcl_Interp *newValuePtr.AP Tcl_Interp *interp inInterpreter containing variable..AP Tcl_Obj *part1Ptr inPoints to a Tcl object containing the variable's name.The name may include a series of \fB::\fR namespace qualifiersto specify a variable in a particular namespace.May refer to a scalar variable or an element of an array variable..AP Tcl_Obj *part2Ptr inIf non-NULL, points to an object containing the name of an elementwithin an array and \fIpart1Ptr\fR must refer to an array variable..AP Tcl_Obj *newValuePtr inPoints to a Tcl object containing the new value for the variable..AP int flags inOR-ed combination of bits providing additional information foroperation. See below for valid values..BE.SH DESCRIPTION.PPThese two procedures may be used to read and modifyTcl variables from C code.\fBTcl_ObjSetVar2\fR will create a new variable or modify an existing one.It sets the specified variable tothe object referenced by \fInewValuePtr\fRand returns a pointer to the object which is the variable's new value.The returned object may not be the same onereferenced by \fInewValuePtr\fR;this might happen because variable traces may modify the variable's value.The reference count for the variable's old value is decrementedand the reference count for its new value is incremented.If the new value for the variableis not the same one referenced by \fInewValuePtr\fR(perhaps as a result of a variable trace),then \fInewValuePtr\fR's reference count is left unchanged.The reference count for the returned object is not incrementedto reflect the returned reference.If the caller needs to keep a reference to the object,say in a data structure,it must increment its reference count using \fBTcl_IncrRefCount\fR.If an error occurs in setting the variable(e.g. an array variable is referencedwithout giving an index into the array),then NULL is returned..PPThe variable name specified to \fBTcl_ObjSetVar2\fR consists of two parts.\fIpart1Ptr\fR contains the name of a scalar or array variable.If \fIpart2Ptr\fR is NULL, the variable must be a scalar.If \fIpart2Ptr\fR is not NULL,it contains the name of an element in the array named by \fIpart2Ptr\fR.As a special case, if the flag TCL_PARSE_PART1 is specified,\fIpart1Ptr\fR may contain both an array and an element name:if the name contains an open parenthesis and ends with aclose parenthesis, then the value between the parentheses istreated as an element name (which can have any string value) andthe characters before the first openparenthesis are treated as the name of an array variable.If the flag TCL_PARSE_PART1 is given,\fIpart2Ptr\fR should be NULL since the array and element namesare taken from \fIpart2Ptr\fR..PPThe \fIflags\fR argument may be used to specify any of severaloptions to the procedures.It consists of an OR-ed combination of any of the followingbits:.TP\fBTCL_GLOBAL_ONLY\fRUnder normal circumstances the procedures look up variables as follows:If a procedure call is active in \fIinterp\fR,a variable is looked up at the current level of procedure call.Otherwise, a variable is looked up first in the current namespace,then in the global namespace.However, if this bit is set in \fIflags\fR then the variableis looked up only in the global namespaceeven if there is a procedure call active.If both \fBTCL_GLOBAL_ONLY\fR and \fBTCL_NAMESPACE_ONLY\fR are given,\fBTCL_GLOBAL_ONLY\fR is ignored..TP\fBTCL_NAMESPACE_ONLY\fRUnder normal circumstances the procedures look up variables as follows:If a procedure call is active in \fIinterp\fR,a variable is looked up at the current level of procedure call.Otherwise, a variable is looked up first in the current namespace,then in the global namespace.However, if this bit is set in \fIflags\fR then the variableis looked up only in the current namespaceeven if there is a procedure call active..TP\fBTCL_LEAVE_ERR_MSG\fRIf an error is returned and this bit is set in \fIflags\fR, thenan error message will be left in the interpreter's result,where it can be retrieved with \fBTcl_GetObjResult\fRor \fBTcl_GetStringResult\fR.If this flag bit isn't set then no error message is leftand the interpreter's result will not be modified..TP\fBTCL_APPEND_VALUE\fRIf this bit is set then \fInewValuePtr\fR is appended to the currentvalue, instead of replacing it.If the variable is currently undefined, then this bit is ignored..TP\fBTCL_LIST_ELEMENT\fRIf this bit is set, then \fInewValuePtr\fR is converted to a validTcl list element before setting (or appending to) the variable.A separator space is appended before the new list element unlessthe list element is going to be the first element in a list orsublist (i.e. the variable's current value is empty, or containsthe single character ``{'', or ends in `` }'')..TP\fBTCL_PARSE_PART1\fRIf this bit is set,then \fBTcl_ObjGetVar2\fR and \fBTcl_ObjSetVar2\fRwill parse \fIpart1Ptr\fRto obtain both an array name and an element name.If the name in \fIpart1Ptr\fR contains an open parenthesisand ends with a close parenthesis,the name is treated as the name of an element of an array;otherwise, the name in \fIpart1Ptr\fRis interpreted as the name of a scalar variable.When this bit is set,\fIpart2Ptr\fR is ignored..PP\fBTcl_ObjGetVar2\fR returns the value of the specified variable.Its arguments are treated the same way as those for \fBTcl_ObjSetVar2\fR.It returns a pointer to the object which is the variable's value.The reference count for the returned object is not incremented.If the caller needs to keep a reference to the object,say in a data structure,it must increment the reference count using \fBTcl_IncrRefCount\fR.If an error occurs in setting the variable(e.g. an array variable is referencedwithout giving an index into the array),then NULL is returned..SH "SEE ALSO"Tcl_GetObjResult, Tcl_GetStringResult, Tcl_GetVar, Tcl_GetVar2, Tcl_SetVar, Tcl_SetVar2, Tcl_TraceVar, Tcl_UnsetVar, Tcl_UnsetVar2.SH KEYWORDSarray, interpreter, object, scalar, set, unset, variable

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -