login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

This is a simple example of writing to and reading from a text file:

fricas
f1: TextFile := open("/tmp/test", "output")

\label{eq1}\verb#"/tmp/test"#(1)
Type: TextFile?
fricas
writeLine!(f1, "abcdefg")

\label{eq2}\verb#"abcdefg"#(2)
Type: String
fricas
close! f1

\label{eq3}\verb#"/tmp/test"#(3)
Type: TextFile?
fricas
f2: TextFile := open("/tmp/test", "input")

\label{eq4}\verb#"/tmp/test"#(4)
Type: TextFile?
fricas
l := readLine! f2

\label{eq5}\verb#"abcdefg"#(5)
Type: String
fricas
output l
abcdefg
Type: Void
fricas
close! f2

\label{eq6}\verb#"/tmp/test"#(6)
Type: TextFile?

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")
134780 134793 4232179
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"

\label{eq7}\verb#"/tmp/test"#(7)
Type: TextFile?
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 graphviz.pdf.xml LatexWiki pts README.txt x.png Z2.lock Z2.pid zopectlsock
Type: Void
fricas
close! f2
(12) "/tmp/test"

\label{eq8}\verb#"/tmp/test"#(8)
Type: TextFile?

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: /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




  Subject: (replying)   Be Bold !!
  ( 15 subscribers )  
Please rate this page: