Tcl Exec-like in STk-2.1.3
I have tried to post this stuff in the News but our server is out....
I think it may be interesting.
-- Erick
--------------------------------------------------------------------
Using following lines should work to have the Tcl exec in STk. This code is in
my
current init.stk file and it will be in the 2.2 release. To use it you must
have
the 2.1.3 release which is available from kaolin.unice.fr
Note: names "port->xxx" have been stolen from scsh documentation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;; Port conversions
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (port->string p)
(unless (or (input-port? p) (input-string-port? p))
(error "port->string: Bad port ~S" p))
;; Read all the lines of port and put them in a string
(let loop ((res "") (line (read-line p)))
(if (eof-object? line)
res
(loop (string-append res "\n" line) (read-line p)))))
(define (port->list reader p)
(unless (or (input-port? p) (input-string-port? p))
(error "port->list: Bad port ~S" p))
;; Read all the lines of port and put them in a list
(let loop ((res '()) (sexp (reader p)))
(if (eof-object? sexp)
(reverse res)
(loop (cons sexp res) (reader p)))))
(define (port->sexp-list p)
(port->list read p))
(define (port->string-list p)
(port->list read-line p))
(define (exec command)
(call-with-input-file (string-append "| " command) port->string))
(define (exec-list command)
(call-with-input-file (string-append "| " command) port->string-list))
-------------------------------------------------------------------------------
Erick Gallesio tel : (33) 92-96-51-53
ESSI - I3S fax : (33) 92-96-51-55
Universite de Nice - Sophia Antipolis email : eg_at_unice.fr
Route des colles
BP 145
06903 Sophia Antipolis CEDEX
FRANCE
-------------------------------------------------------------------------------
Received on Wed Oct 26 1994 - 18:10:21 CET
This archive was generated by hypermail 2.3.0
: Mon Jul 21 2014 - 19:38:59 CEST