+int pat_constv(Tcl_Interp *ip, Tcl_Obj *var,
+ Tcl_Obj **val_r, Tcl_ObjType *type) {
+ int rc;
+ Tcl_Obj *val;
+
+ val= Tcl_ObjGetVar2(ip,var,0,TCL_LEAVE_ERR_MSG);
+ if (!val) return TCL_ERROR;
+
+ if (type) {
+ rc= Tcl_ConvertToType(ip,val,type);
+ if (rc) return rc;
+ }
+
+ *val_r= val;
+ return TCL_OK;
+}
+