#!/usr/bin/newlisp
; --- runtk v 1.4 updated for 10.1 LM Nov 27th, 2009 ---
;
; original version bye Fanda:
; http://www.intricatevisions.com/index.cgi?page=newlisp
;
; Run programs written for newlisp-tk without without it
; Only newLISP and a installation of Tcl/Tk is required.
;
; EXAMPLE on Linux/UNIX and Win32:
;
; runtk myprog.lsp
;
; myprog.lsp could also be directly embedded
; inside this wrapper (see bottom of this file).
; setup communications to Tcl/Tk
(map set '(myin tcout) (pipe))
(map set '(tcin myout) (pipe))
(process "/usr/bin/wish" tcin tcout)
; tk function to pass commands to Tcl/Tk
(define (tk)
(write-line myout (append "if { [catch { puts ["
(apply string (args)) "] }] } { "
[text] tk_messageBox -message $errorInfo; exit }
[/text]))
(let (str "")
(while (starts-with (setq str (read-line myin)) "newLISP:")
(eval-string ((length "newLISP: ") -1 str)))
str))
(global 'tk)
;; this is for compatibility with newlisp-tk for running
;; the Demo.lsp programs distributed with newlisp-tk
;; for new programs just use 'puts' without the 'Newlisp' wrapper
(tk "proc Newlisp { command } { puts $command }")
;; exit when main window is closed
(tk "bind . <Destroy> {puts {(exit)}}")
;; get program from command line or insert the program here
(load (main-args 2))
;; process incoming newLISP requests
(while (read-line myin)
(eval-string (current-line)))
;; eof
syntax highlighting with newLISP and syntax.cgi