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

Edit detail for SandBox Text Files revision 1 of 1

1
Editor:
Time: 2007/11/18 18:43:13 GMT-8
Note:

changed:
-
This is a simple example of writing to and reading from a text file:
\begin{axiom}
f1: TextFile := open("/tmp/test", "output")
writeLine!(f1, "abcdefg")
close! f1
f2: TextFile := open("/tmp/test", "input")
l := readLine! f2
output l
close! f2
\end{axiom}

Here is a system command. It display how many files there are
in the default current directory where Axiom is run.
\begin{axiom}
)set output algebra on
systemCommand("system ls | wc")
\end{axiom}

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:
\begin{axiom}
)set output algebra on
systemCommand("system ls .. > /tmp/test")
\end{axiom}

\begin{axiom}
f2: TextFile := open("/tmp/test", "input")
while not endOfFile? f2 repeat
    s := readLine! f2
    output s
close! f2
\end{axiom}

Here is an example of how to call a polymake constructor.
Notice that you must use the full path name.
\begin{axiom}
)set output algebra on
systemCommand("system /usr/local/polymake/bin/cube /tmp/cube4.poly 4 2>/tmp/cube4.stderr >/tmp/cube4.stdout")
\end{axiom}
Here is the standard output of the command (if any):
\begin{axiom}
systemCommand("system cat /tmp/cube4.stdout")
\end{axiom}
Here is the error output of the command (if any):
\begin{axiom}
systemCommand("system cat /tmp/cube4.stderr")
\end{axiom}

Now display the contents of the file that was created:
\begin{axiom}
f2: TextFile := open("/tmp/cube4.poly", "input")
while not endOfFile? f2 repeat
    s := readLine! f2
    output s
close! f2
\end{axiom}

From kratt6 Fri Aug 26 16:55:21 -0500 2005
From: kratt6
Date: Fri, 26 Aug 2005 16:55:21 -0500
Subject: 
Message-ID: <20050826165521-0500@page.axiom-developer.org>

\begin{axiom}
systemCommand("system /usr/local/polymake/bin/cross /tmp/c4.poly 4")
systemCommand("system cat /tmp/c4.poly")
\end{axiom}

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

fricas
(1) -> 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")
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"

\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 LatexWiki README.txt Z2.lock Z2.pid graphviz.pdf.xml pts revisions.xml x.png 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: 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