0

If possible, I would want my customised "puts" to be able to provide the timestamp during my code.

Not sure, if an interpreter allows you to do this...

Any close enough ideas are welcome.

Thanks, Tanbir

4

2 回答 2

0

您是否正在寻找这样的东西:

    % info commands puts
    puts
    % rename puts my_puts
    % proc puts {arg} {
        my_puts "[clock format [clock seconds] -format %c]: $arg"
    }
    % puts "Hello world!"
    Thu Oct 15 11:23:34 2020: Hello world!
于 2020-10-15T05:54:20.170 回答
0

TCL 命令在加载 TCL 时加载到全局命名空间中。你可以用infoTCL来探索。

% info anything_invalid
unknown or ambiguous subcommand "anything_invalid": must be args, body, cmdcount, commands, complete, default, exists, frame, functions, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars
%

可用的内置命令列表:

% info commands
tell socket subst open eof pwd glob list pid exec auto_load_index time unknown eval lassign lrange fblocked lsearch auto_import gets case lappend proc break variable llength auto_execok return linsert error catch clock info split array if fconfigure concat join lreplace source fcopy global switch auto_qualify update close cd for auto_load file append lreverse format unload read package set binary namespace scan apply trace seek while chan flush after vwait dict continue uplevel foreach lset rename fileevent regexp lrepeat upvar encoding expr unset load regsub history interp exit puts incr lindex lsort tclLog string
%
于 2021-03-04T09:21:11.487 回答