Prev: Mac OS: Search entry in Help menu
Next: Fail to load the compiled tclreg12.dll (was:load tk85.dll fail)
From: pmarin on 16 Jan 2010 13:45 Hi all. I want to implement a primitive procedure in Muddy scheme (http:// wiki.tcl.tk/25512) that return to the tclshell so I can debug the interpreter's data structures. I tried setting tcl_interactive to 0 but not work. The quit procedure: def quit_proc {args} { global object_type global tcl_interactive global _exit set _exit 1 set ::tcl_interactive 1 return [Object new $object_type(STRING) "bye..."] } and the main fuction is: proc main {} { global the_global_environment global _exit set rchar [ReadChar new] set _exit 0 puts "Welcome to Muddy Scheme, Copyright (c) 2010 Franciso José Marín Pérez" puts "Use ctrl-c to exit." while {!$_exit} { puts -nonewline "> " flush stdout write [_eval [_read $rchar] $the_global_environment ] puts "" flush stdout } }
From: Bruce Hartweg on 16 Jan 2010 17:27 pmarin wrote: > Hi all. > I want to implement a primitive procedure in Muddy scheme (http:// > wiki.tcl.tk/25512) that return to the tclshell so I can debug the > interpreter's data structures. I tried setting tcl_interactive to 0 > but not work. > the tcl_interactive variable just controls how some functions behave (like unknown autocompletion/autoexecing behavior) but does not do anything magic with reading/interpreting actions if tclsh is called with a script it then runs that script and exits. in your case once main is called that is the end of your s script. if you want interactive behavior you need to add code after main exits to check your flag, and then enter a read/eval function of tcl commands (using info complete) or easier yet just run tclsh without your muddy.tcl script so it is in interactive mode and handles user interactinos correclty, then manually source your script, then when your main function ends you will still be in your interactive shell Bruce
From: pmarin on 16 Jan 2010 18:04
It was a stupid question, you are right, I only have to run tclsh without sourcing muddy.tcl and now I can return to tclsh with (quit). Thank you Bruce. |