|  |  4.10.4 ASCII links 
Via ASCII links data that can be converted to a string can be written
into files for storage or communication with other programs. The data is
written in plain ASCII format. The output format of polynomials is done
w.r.t. the value of the global variable short(see  short).
Reading from an ASCII link returns a string -- conversion into other data
is up to the user. This can be done, for example,
using the commandexecute(see  execute). 
The ASCII link describing string has to be one of the following:
 
 
"ASCII: "+ filenamethe mode (read or append) is set by the first
 readorwritecommand."ASCII:r "+ filenameopens the file for reading.
"ASCII:w "+ filenameopens the file for overwriting.
"ASCII:a "+ filenameopens the file for appending.
 
There are the following default values:
 
the type ASCIImay be omitted since ASCII links are the
default links.
if non of r,w, orais specified, the mode of
the link is set by the firstreadorwritecommand on the
link. If the first command iswrite, the mode is set toa(append mode).
if the filename is omitted, readreads from stdin andwritewrites to stdout. 
Using these default rules, the string ":r temp"describes a link
which is equivalent to the link"ASCII:r temp": an ASCII link to
the filetempwhich is opened for reading. The string"temp"describes an ASCII link to the filetemp, where the
mode is set by the firstreadorwritecommand. See also
the example below. 
Note that the filename may contain a path. On Microsoft Windows
(resp. MS-DOS) platforms, names of a drive can precede the filename, but
must be started with a //(as in//c/temp/ex. An ASCII
link can be used either for reading or for writing, but not for both at
the same time. Aclosecommand must be used before a change of
I/O direction. Types without a conversion tostringcannot be
written. 
Example:
 |  |   ring r=32003,(x,y,z),dp;
  link l=":w example.txt";     // type is ASCII, mode is overwrite
  l;
==> // type : ASCII
==> // mode : w
==> // name : example.txt
==> // open : no
==> // read : not ready
==> // write: not ready
  status(l, "open", "yes");    // link is not yet opened
==> 0
  ideal i=x2,y2,z2;
  write (l,1,";",2,";","ideal i=",i,";");
  status(l, "open", "yes");    // now link is open
==> 1
  status(l, "mode");           // for writing
==> w
  close(l);                    // link is closed
  write("example.txt","int j=5;");// data is appended to file
  read("example.txt");         // data is returned as string
==> 1
==> ;
==> 2
==> ;
==> ideal i=
==> x2,y2,z2;
==> int j=5;
==> 
  execute(read(l));            // read string is executed
==> 1
==> 2
==> // ** redefining i (ideal i=) ./examples/ASCII_links.sing:14
  close(l);                    // link is closed
 | 
 
 |