Manual Pages for UNIX Darwin command on man Tcl_Eval
MyWebUniversity

Manual Pages for UNIX Darwin command on man Tcl_Eval

TclEval(3) Tcl Library Procedures TclEval(3)

NAME

TclEvalObjEx, TclEvalFile, TclEvalObjv, TclEval, TclEvalEx,

TclGlobalEval, TclGlobalEvalObj, TclVarEval, TclVarEvalVA - execute

Tcl scripts

SYNOPSIS

##iinncclluuddee <>

int | TTccllEEvvaallOObbjjEExx(interp, objPtr, flags) | int | TTccllEEvvaallFFiillee(interp, fileName) | int | TTccllEEvvaallOObbjjvv(interp, objc, objv, flags) | int | TTccllEEvvaall(interp, script) | int | TTccllEEvvaallEExx(interp, script, numBytes, flags) | int | TTccllGGlloobbaallEEvvaall(interp, script) | int | TTccllGGlloobbaallEEvvaallOObbjj(interp, objPtr) | int | TTccllVVaarrEEvvaall(interp, string, string, ... ((cchhaarr **)) NNUULLLL) | int | TTccllVVaarrEEvvaallVVAA(interp, argList) | AARRGGUUMMEENNTTSS | TclInterp *interp (in) || Interpreter in which to execute the | script. The interpreter's result | is modified to hold the result or | error message from the script. | TclObj *objPtr (in) || A Tcl object containing the script | to execute. | int flags (in) || ORed combination of flag bits that | specify additional options. | TTCCLLEEVVAALLGGLLOOBBAALL and TTCCLLEEVVAALLDDIIRREECCTT | are currently supported. |

CONST char *file- |

Name (in) | | Name of a file containing a Tcl | script. | int objc (in) || The number of objects in the array | pointed to by objPtr; this is also | the number of words in the command. | TclObj **objv (in) || Points to an array of pointers to | objects; each object holds the |

value of a single word in the com- |

mand to execute. |

int num- |

Bytes (in) | | The number of bytes in script, not | including any null terminating |

character. If -1, then all charac- |

ters up to the first null byte are | used. | CONST | char *script (in) | | Points to first byte of script to |

execute (null-terminated and |

UTF-8). |

char *string (in) || String forming part of a Tcl | script. | valist argList (in) || An argument list which must have | been initialised using | TTCCLLVVAARRAARRGGSSSSTTAARRTT, and cleared | using vvaaeenndd. | |

DESCRIPTION

The procedures described here are invoked to execute Tcl scripts in | various forms. TTccllEEvvaallOObbjjEExx is the core procedure and is used by many | of the others. It executes the commands in the script stored in objPtr | until either an error occurs or the end of the script is reached. If |

this is the first time objPtr has been executed, its commands are com- |

piled into bytecode instructions which are then executed. The byte- |

codes are saved in objPtr so that the compilation step can be skipped | if the object is evaluated again in the future. | The return value from TTccllEEvvaallOObbjjEExx (and all the other procedures | described here) is a Tcl completion code with one of the values TTCCLLOOKK, | TTCCLLEERRRROORR, TTCCLLRREETTUURRNN, TTCCLLBBRREEAAKK, or TTCCLLCCOONNTTIINNUUEE, or possibly some | other integer value originating in an extension. In addition, a result | value or error message is left in interp's result; it can be retrieved | using TTccllGGeettOObbjjRReessuulltt. |

TTccllEEvvaallFFiillee reads the file given by fileName and evaluates its con- |

tents as a Tcl script. It returns the same information as TTccllEEvvaallOObb- |

jjEExx. If the file couldn't be read then a Tcl error is returned to | describe why the file couldn't be read. The eofchar for files is '\32' | (^Z) for all platforms. If you require a ``^Z'' in code for string | comparison, you can use ``\032'' or ``\u001a'', which will be safely | substituted by the Tcl interpreter into ``^Z''.

TTccllEEvvaallOObbjjvv executes a single pre-parsed command instead of a script.

The objc and objv arguments contain the values of the words for the Tcl command, one word in each object in objv. TTccllEEvvaallOObbjjvv evaluates the

command and returns a completion code and result just like TTccllEEvvaallOObb-

jjEExx.

TTccllEEvvaall is similar to TTccllEEvvaallOObbjjEExx except that the script to be exe-

cuted is supplied as a string instead of an object and no compilation

occurs. The string should be a proper UTF-8 string as converted by

TTccllEExxtteerrnnaallTTooUUttffDDSSttrriinngg or TTccllEExxtteerrnnaallTTooUUttff when it is known to pos-

sibly contain upper ASCII characters who's possible combinations might

be a UTF-8 special code. The string is parsed and executed directly

(using TTccllEEvvaallOObbjjvv) instead of compiling it and executing the byte-

codes. In situations where it is known that the script will never be executed again, TTccllEEvvaall may be faster than TTccllEEvvaallOObbjjEExx. TTccllEEvvaall returns a completion code and result just like TTccllEEvvaallOObbjjEExx. Note: for backward compatibility with versions before Tcl 8.0, TTccllEEvvaall

copies the object result in interp to interp->result (use is depre-

cated) where it can be accessed directly. This makes TTccllEEvvaall somewhat slower than TTccllEEvvaallEExx, which doesn't do the copy. TTccllEEvvaallEExx is an extended version of TTccllEEvvaall that takes additional arguments numBytes and flags. For the efficiency reason given above, TTccllEEvvaallEExx is generally preferred over TTccllEEvvaall. TTccllGGlloobbaallEEvvaall and TTccllGGlloobbaallEEvvaallOObbjj are older procedures that are now deprecated. They are similar to TTccllEEvvaallEExx and TTccllEEvvaallOObbjjEExx except that the script is evaluated in the global namespace and its variable

context consists of global variables only (it ignores any Tcl proce-

dures that are active). These functions are equivalent to using the TTCCLLEEVVAALLGGLLOOBBAALL flag (see below).

TTccllVVaarrEEvvaall takes any number of string arguments of any length, con-

catenates them into a single string, then calls TTccllEEvvaall to execute that string as a Tcl command. It returns the result of the command and

also modifies interp->result in the same way as TTccllEEvvaall. The last

argument to TTccllVVaarrEEvvaall must be NULL to indicate the end of arguments. TTccllVVaarrEEvvaall is now deprecated. TTccllVVaarrEEvvaallVVAA is the same as TTccllVVaarrEEvvaall except that instead of taking a variable number of arguments it takes an argument list. Like TTccllVVaarrEEvvaall, TTccllVVaarrEEvvaallVVAA is deprecated. FFLLAAGG BBIITTSS Any ORed combination of the following values may be used for the flags argument to procedures such as TTccllEEvvaallOObbjjEExx: TTCCLLEEVVAALLDDIIRREECCTT This flag is only used by TTccllEEvvaallOObbjjEExx; it is ignored by other procedures. If this flag bit is set, the script is not compiled to bytecodes; instead it is executed directly as is done by TTccllEEvvaallEExx. The TTCCLLEEVVAALLDDIIRREECCTT flag is useful in situations where the contents of an object

are going to change immediately, so the byte-

codes won't be reused in a future execution. In this case, it's faster to execute the script directly. TTCCLLEEVVAALLGGLLOOBBAALL If this flag is set, the script is processed at global level. This means that it is evaluated in the global namespace and its variable context consists of global variables only (it ignores any Tcl procedures at are active). MMIISSCCEELLLLAANNEEOOUUSS DDEETTAAIILLSS During the processing of a Tcl command it is legal to make nested calls to evaluate other commands (this is how procedures and some control structures are implemented). If a code other than TTCCLLOOKK is returned from a nested TTccllEEvvaallOObbjjEExx invocation, then the caller should normally return immediately, passing that same return code back to its caller,

and so on until the top-level application is reached. A few commands,

like ffoorr, will check for certain return codes, like TTCCLLBBRREEAAKK and TTCCLLCCOONNTTIINNUUEE, and process them specially without returning. TTccllEEvvaallOObbjjEExx keeps track of how many nested TTccllEEvvaallOObbjjEExx invocations are in progress for interp. If a code of TTCCLLRREETTUURRNN, TTCCLLBBRREEAAKK, or TTCCLLCCOONNTTIINNUUEE is about to be returned from the topmost TTccllEEvvaallOObbjjEExx invocation for interp, it converts the return code to TTCCLLEERRRROORR and sets interp's result to an error message indicating that the rreettuurrnn, bbrreeaakk, or ccoonnttiinnuuee command was invoked in an inappropriate place. This

means that top-level applications should never see a return code from

TTccllEEvvaallOObbjjEExx other then TTCCLLOOKK or TTCCLLEERRRROORR. KKEEYYWWOORRDDSS execute, file, global, object, result, script Tcl 8.1 TclEval(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™