1Tcl_SubstObj(3)             Tcl Library Procedures             Tcl_SubstObj(3)
2
3
4
5______________________________________________________________________________
6

NAME

8       Tcl_SubstObj - perform substitutions on Tcl objects
9

SYNOPSIS

11       #include <tcl.h>
12
13       Tcl_Obj *
14       Tcl_SubstObj(interp, objPtr, flags)
15

ARGUMENTS

17       Tcl_Interp   *interp      (in)      Interpreter in which to execute Tcl
18                                           scripts and lookup  variables.   If
19                                           an  error occurs, the interpreter's
20                                           result is modified to hold an error
21                                           message.
22
23       Tcl_Obj      *objPtr      (in)      A  Tcl object containing the string
24                                           to perform substitutions on.
25
26       int          flags        (in)      ORed combination of flag bits  that
27                                           specify which substitutions to per‐
28                                           form.   The  flags   TCL_SUBST_COM‐
29                                           MANDS,    TCL_SUBST_VARIABLES   and
30                                           TCL_SUBST_BACKSLASHES are currently
31                                           supported,   and  TCL_SUBST_ALL  is
32                                           provided as a convenience  for  the
33                                           common case where all substitutions
34                                           are desired.
35_________________________________________________________________
36
37

DESCRIPTION

39       The Tcl_SubstObj function is used to perform substitutions  on  strings
40       in  the  fashion of the subst command.  It gets the value of the string
41       contained in objPtr and scans it, copying characters and performing the
42       chosen  substitutions  as it goes to an output object which is returned
43       as the result of the function.  In the event of an error occurring dur‐
44       ing  the  execution of a command or variable substitution, the function
45       returns NULL and an error message is left in interp's result.
46
47       Three kinds of substitutions are supported.  When  the  TCL_SUBST_BACK‐
48       SLASHES bit is set in flags, sequences that look like backslash substi‐
49       tutions for Tcl commands are replaced by their corresponding character.
50
51       When the TCL_SUBST_VARIABLES bit is set in flags, sequences  that  look
52       like  variable  substitutions for Tcl commands are replaced by the con‐
53       tents of the named variable.
54
55       When th TCL_SUBST_COMMANDS bit is set in  flags,  sequences  that  look
56       like  command substitutions for Tcl commands are replaced by the result
57       of evaluating that script.  Where an uncaught continue exception occurs
58       during  the  evaluation  of  a command substitution, an empty string is
59       substituted for the command.  Where an uncaught break exception  occurs
60       during  the  evaluation  of  a  command substitution, the result of the
61       whole substitution on objPtr will be truncated at the point immediately
62       before the start of the command substitution, and no characters will be
63       added to the result or substitutions performed after that point.
64
65

SEE ALSO

67       subst(n)
68
69

KEYWORDS

71       backslash substitution, command substitution, variable substitution
72
73
74
75Tcl                                   8.4                      Tcl_SubstObj(3)
Impressum