Search code examples
tclexpectreadline

Tcl interact after sourcing a file.tcl


I want to interact after sourcing a file in Tcl prompt. i.e.,

]$ tclsh myCode.tcl

// execute my code

% // Enters Interact mode within myCode.tcl


Solution

  • The simplest way of doing this is to use the commandloop command from the TclX extension.

    package require Tclx
    
    #... define things and run things...
    
    # Let the user issue commands
    commandloop
    

    The wiki page linked above discusses how to do this without using TclX.