Tanbir
Tanbir

Reputation: 65

Where are all the keywords stored in tclsh? If yes, is there a way to run a customized "puts" in tclsh?

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

Upvotes: 0

Views: 45

Answers (2)

Sharad
Sharad

Reputation: 10612

TCL commands are loaded in the global namespace upon loading TCL. You can use info to explore TCL.

% 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
%

List of available inbuilt commands:

% 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
%

Upvotes: 1

Sharad
Sharad

Reputation: 10612

Are you looking for something like this:

    % 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!

Upvotes: 1

Related Questions