In autolisp you can define a lisp-command without paranthesis by make an defun with an "C:" before the lisp-function name.
(defun C:Testfunc () (setq banana 1))
At the console-prompt you can type "Testfunc" and it's starts.
Would it be possible to add such or similar option to newlisp.
When we make then an application with a console window
a direct command-typing would be possible without paranthesis.
The command would then ask interactivly about input data.
After some thoughts about the problem, it should be possible just by modifying the TCL-code of the console. Just compare the input against a command-list and when the input-string is in the command-list, make a proper lisp-call out of it and send it to newlisp. So the define could stay as it is and we have only to set up the command-list.
The function to modify in newlisp-tk.tcl would be 'ProcessConsoleInput()' before the second to last line which says: 'puts $nlio $lastCommand' , you could check the contents of last command and than replace it with a newLISP command with parenthesis etc.:
----------------- before -------------------
update
puts $nlio $lastCommand
flush $nlio
----------------- after ---------------------
update
if { $lastCommand == "dir" } { set lastCommand "(directory)" }
if { $lastCommand == "syms" } { set lastCommand "(symbols)" }
puts $nlio $lastCommand
flush $nlio
----------------------------------------------
I tried it out and it works fine for me.
Lutz
Thanks again Lutz,
Exactly what I wanted to do, but I was not so fast as you.
(You know your code best)
That is what I like very much on newlisp:
Powerfull flexibility!!
First class response-quality and time!
For a more general solution I do this:
#In the global var-section
set Ide(DirectConsoleCmd) {dir syms}
set Ide(DirectLispCmd) {directory symbols}
#in proc ProcessConsoleInput
# if { $lastCommand == "dir" } { set lastCommand "(directory)" }
# if { $lastCommand == "syms" } { set lastCommand "(symbols)" }
if { [llength $Ide(DirectConsoleCmd)] > 0 } {
set cmdpos [lsearch $Ide(DirectConsoleCmd) $lastCommand]
if { $cmdpos > -1 } {
set lastCommand "("
append lastCommand [lindex $Ide(DirectLispCmd) $cmdpos] ")"
}
}
Now I want to set it dynamicly from lisp. See the different thread on problems with accessing TK-variables. Then no re-wrap is needed.
Another little improvment:
if { [llength $Ide(DirectConsoleCmd)] > 0 } {
set cmdpos [lsearch $Ide(DirectConsoleCmd) [string tolower $lastCommand]]
if { $cmdpos > -1 } {
set lastCommand "("
append lastCommand [lindex $Ide(DirectLispCmd) $cmdpos] ")"
}
}
With this the commands are case-insensitive.
if { [llength $Ide(DirectConsoleCmd)] > 0 } {
set cmdpos [lsearch -exact $Ide(DirectConsoleCmd) [string tolower $lastCommand]]
if { $cmdpos > -1 } {
set lastCommand "("
append lastCommand [lindex $Ide(DirectLispCmd) $cmdpos] ")"
}
}
Adding the '-exact' option will prevent to activate the first command through input of '*'. Or something like 'd*'. Only the exact command will trigger.