Tcl_RecordAndEval(3)
π Tcl_RecordAndEval β bestie edition π
okay so this is a page from the Tcl Library Procedures manual (section 3, the C-function girlies β¨), and it's all about saving a command to the history list before you run it. so basically: remember it, then do it. iconic behaviour honestly π
β¨ NAME β¨
Tcl_RecordAndEval β save command on history list before evaluating π«Ά
πΈ SYNOPSIS πΈ
#include <tcl.h>
int
Tcl_RecordAndEval(interp, cmd, flags)
π ARGUMENTS π
Tcl_Interp *interp(in) β the Tcl interpreter where we're gonna evaluate the command. it's giving main character energy, everything happens here.const char *cmd(in) β the command (or a whole sequence of commands, no judgement) to execute.int flags(in) β an OR'ed combination of flag bits. two of them, bestie:TCL_NO_EVALmeans record the command but do not evaluate it. so it goes in the history, it just doesn't run. it's lurking. πTCL_EVAL_GLOBALmeans evaluate the command at global level instead of the current stack level. we're going up top for this one π
π DESCRIPTION π
Tcl_RecordAndEval gets invoked to record a command as an event on the history list, and then execute it using Tcl_Eval β or Tcl_GlobalEval if the TCL_EVAL_GLOBAL bit is set in flags. slay.
It returns a completion code such as TCL_OK just like Tcl_Eval does, and it leaves information in the interpreter's result. same energy, same contract π
If you do not want the command recorded on the history list, then you should invoke Tcl_Eval instead of Tcl_RecordAndEval. periodt. no history for you.
Normally Tcl_RecordAndEval is only called with top-level commands typed by the user, because the whole purpose of history is to let the user re-issue recently-invoked commands. it's the "up arrow" of the C API, lowkey π¦
If the flags argument contains the TCL_NO_EVAL bit, then the command is recorded without being evaluated. (yes we said it already, it's important okay π)
Note note note:Tcl_RecordAndEvalhas been largely replaced by the value-based procedureTcl_RecordAndEvalObj. that value-based procedure records and optionally executes a command held in a Tcl value instead of a string. so if you're writing new code, that's the one, iykyk π
π SEE ALSO π
Tcl_RecordAndEvalObj
β KEYWORDS β
command, event, execute, history, interpreter, record
and that's the whole page bestie, we ate and left no crumbs ππ β¨
this one came from the Tcl library docs, version 7.4, manual section 3 β so go forth and record responsibly, mwah ππ§π
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- Copyright (c) 1989-1993 The Regents of the University of California
- Copyright (c) 1994-1997 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms