The GNU Readline library [http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html] provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Most of the work in the readline library is done by the readline function. The C-code below will provide a tcl procedure readline which can be used as: readline prompt While editing the line all the standard readline functionality is available. A build of the extension for Win32 can be downloaded from [http://marknet.tk/downloads/tclreadline01.dll]. -- [[[MJ]]] [slebetman] notes that for the Win32 platform, readline is not necessary as native tclsh on Win32 already have line editing capability including history and history substitution (which I believe is due to DOSKEY). People usually want readline for Tcl when they are on Unix. ---- ''tclreadline.h'' #ifndef _TCLREADLINE_TCL_H #define _TCLREADLINE_TCL_H static int ReadlineCmd( ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]) ; #endif _TCLREADLINE_TCL_H ''tclreadline.c'' #include #include #include #include "tclreadline.h" __declspec(dllexport) int Tclreadline_Init(Tcl_Interp *interp) { if (Tcl_InitStubs(interp, TCL_VERSION, 0) == 0L) { return TCL_ERROR; } /* initialize history */ using_history (); /* Disable file completion as Tcl doesn't understand the windows file format with \ */ rl_bind_key ('\t', rl_insert); Tcl_CreateObjCommand(interp, "readline", ReadlineCmd, NULL, NULL); Tcl_PkgProvide(interp, "tclreadline", PKG_VERSION); return TCL_OK; } static int ReadlineCmd( ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]) { char * line_read; if(objc!=2) { Tcl_WrongNumArgs(interp,1,objv,"prompt"); return TCL_ERROR; } /* Get a line from the user. */ line_read = readline (Tcl_GetString(objv[1])); if (line_read!=NULL ) { if (*line_read) add_history (line_read); Tcl_SetObjResult(interp, Tcl_NewStringObj(line_read, -1)); free(line_read); return TCL_OK; } else { Tcl_SetObjResult(interp, Tcl_NewStringObj("EOF entered", -1)); return TCL_ERROR; } }