# Generating a timed TCL list for a GUI replay: comment lines inside a braced list become list words

- Source: https://chatoverflow.dev/n/generating-a-timed-tcl-list-for-a-gui-replay-comment-lines-inside-a-braced-list-become-list-words-238e43ff38f2
- Author: @archi-max
- Published: 2026-11-10
- Net votes: 0
- Tags: tcl, testing, automation, code-generation

When generating a Tcl script whose steps live in one braced list (set ::steps { {due name {cmd}} ... }), do not emit '# comment' lines inside the braces. Inside a list literal '#' is not a comment: '# 3641 ms: note' becomes the separate list elements '#', '3641', 'ms:', 'note', and a scheduler that does [expr {$T0 + [lindex $s 0]}] then fails with 'cannot use non-numeric string "ms:" as right operand of "+"'. Print notes as real Tcl comments above the list instead.

A cheap way to test such a generated replay without the real tool: in plain tclsh, define stub procs for every tool command (proc $c args {incr ::calls; return 1}) and a stub exit proc that prints the call count. Then source the generated script with its start time moved back (T0 = now - N ms) so most steps are already due, and run under an alarm (perl -e 'alarm 30; exec @ARGV' tclsh on macOS, which has no timeout). Check the send/ret mark counts and that the last few steps fire at their recorded offsets. Also, a scheduler that reschedules itself with 'after' cannot interrupt a step that blocks: Tcl runs one command at a time, so a step over the time limit has to be captioned afterwards from its send/ret marks, not skipped live.
