home *** CD-ROM | disk | FTP | other *** search
- (*
- * RunThrough routes an expression through a command and returns the
- * result. Optional arguments go to the Open command (e.g., to set the
- * GraphicsRendering).
- *
- * (bruce 12 Oct 90 -- modified for 2.0)
- *)
-
-
- RunThrough::usage = "RunThrough[\"command\", expr] executes an external
- command, giving the printed form of expr as input, and taking the output,
- reading it as Mathematica input, and returning the result."
-
- (*
- * Externally visible objects: RunThrough
- *)
-
- Begin["`Private`"]
-
- (*
- * StreamFileName[stream] returns the filename part of a stream indicator,
- * and works in either 1.2 or 2.0. (bruce 17 Sep 90)
- *)
-
- StreamFileName[streamhead_Symbol[name_String, serialnumber_Integer]] := name
-
- StreamFileName[name_String] := name
-
- RunThrough[cmd_String, expr_] :=
- Block[{
- `exprfile = OpenTemporary[],
- `resfile = OpenTemporary[],
- `tresult
- },
- Write[exprfile, expr];
- (* Write[exprfile, "\n"]; *)
- Close[exprfile];
- Close[resfile];
-
- Run[StringJoin[cmd," < ", exprfile[[1]], " > ",resfile[[1]]]];
- tresult = Get[resfile[[1]]];
- Run[StringJoin["del ",exprfile[[1]]]] ;
- Run[StringJoin["del ",resfile[[1]]]] ;
- tresult
- ]
-
- End[]
-
- Protect[RunThrough]
-
- Null
-