Tcl_RecordAndEval(3tcl)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– Tcl_RecordAndEval β€” bestie edition πŸ’–

okay so you're in the Tcl Library Procedures corner of the manual and the page we're doing today is Tcl_RecordAndEval. she's giving history-list girlie and honestly? she ate. let's go 🌸


✨ 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 you wanna evaluate the command. literally the whole vibe lives in here πŸ’œ
  • const char *cmd (in) β€” the command (or a whole sequence of commands, she's flexible) that you want to execute ✨
  • int flags (in) β€” an OR'ed-together combo of flag bits, no cap:
    • TCL_NO_EVAL means record the command but do not evaluate it πŸ™ˆ
    • TCL_EVAL_GLOBAL means evaluate the command at global level instead of the current stack level πŸ‘‘

🌸 DESCRIPTION 🌸

So Tcl_RecordAndEval is the function you call when you want to record a command as an event on the history list and then run it using Tcl_Eval (or Tcl_GlobalEval if the TCL_EVAL_GLOBAL bit is set in flags). she does both. multitasking icon πŸ’…

She returns a completion code like TCL_OK β€” exactly like Tcl_Eval does β€” and she leaves info chillin' in the interpreter's result. 🫢

bestie, listen: if you do not want the command recorded on the history list, then you should invoke Tcl_Eval instead of Tcl_RecordAndEval. that's the whole difference. periodt.

Normally Tcl_RecordAndEval is only called with top-level commands typed by the user, because the entire point of history is to let the user re-issue recently-invoked commands. it's giving up-arrow energy β¬†οΈβœ¨

And if the flags argument contains the TCL_NO_EVAL bit, then the command gets recorded without being evaluated. recorded but not performed. the ultimate "not me, I'm just watching" move 😭

Also lowkey important: note that Tcl_RecordAndEval has been largely replaced by the value-based procedure Tcl_RecordAndEvalObj. that value-based procedure records and optionally executes a command held in a Tcl value instead of a string. so like, glow-up version, same soul πŸ’–


πŸŽ€ SEE ALSO πŸŽ€

  • Tcl_RecordAndEvalObj β€” her value-based sister, go say hi πŸ¦‹

⭐ KEYWORDS ⭐

command, event, execute, history, interpreter, record


mwah πŸ’‹ this page is from the Tcl library manual, version 7.4, dated 7.4 β€” ily, go record some history and slay responsibly πŸ‘‘πŸŒˆ

πŸ“¦ where this page comes from