This is a simple example of writing to and reading from a text file:
fricas
(1) -> f1: TextFile := open("/tmp/test", "output")
fricas
writeLine!(f1, "abcdefg")
Type: String
fricas
close! f1
fricas
f2: TextFile := open("/tmp/test", "input")
fricas
l := readLine! f2
Type: String
fricas
output l
abcdefg
Type: Void
fricas
close! f2
Here is a system command. It display how many files there are
in the default current directory where Axiom is run.
fricas
)set output algebra on
systemCommand("system ls | wc")
106805 106818 3417692
Type: Void
Please do not try to list the complete contents of this directory!
If you do, MathAction will appear to hang.
Here is a shorter list of files that works ok:
fricas
)set output algebra on
systemCommand("system ls .. > /tmp/test")
Type: Void
fricas
f2: TextFile := open("/tmp/test", "input")
(10) "/tmp/test"
fricas
while not endOfFile? f2 repeat
s := readLine! f2
output s
Data.fs
Data.fs.index
Data.fs.lock
Data.fs.old
Data.fs.tmp
LatexWiki
README.txt
Z2.lock
Z2.pid
graphviz.pdf.xml
pts
revisions.xml
x.png
zopectlsock
Type: Void
fricas
close! f2
(12) "/tmp/test"
Here is an example of how to call a polymake constructor.
Notice that you must use the full path name.
fricas
)set output algebra on
systemCommand("system /usr/local/polymake/bin/cube /tmp/cube4.poly 4 2>/tmp/cube4.stderr >/tmp/cube4.stdout")
Type: Void
Here is the standard output of the command (if any):
fricas
systemCommand("system cat /tmp/cube4.stdout")
Type: Void
Here is the error output of the command (if any):
fricas
systemCommand("system cat /tmp/cube4.stderr")
/bin/sh: 1: /usr/local/polymake/bin/cube: not found
Type: Void
Now display the contents of the file that was created:
fricas
f2: TextFile := open("/tmp/cube4.poly", "input")
>> Error detected within library code:
"File is not readable""/tmp/cube4.poly"
fricas
systemCommand("system /usr/local/polymake/bin/cross /tmp/c4.poly 4")
Type: Void
fricas
systemCommand("system cat /tmp/c4.poly")
Type: Void