Home Online Manual
Top
Back: Ssi links
Forward: Ssi tcp links
FastBack: ASCII links
FastForward: Pipe links
Up: Ssi links
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

4.9.5.1 Ssi file links

Ssi file links provide the possibility to store data in a file using the ssi format. For storing large amounts of data, ssi file links should be used instead of ASCII links. Unlike ASCII links, data read from ssi file links is returned as expressions one at a time.

The ssi file link describing string has to be one of the following:

  1. "ssi:r " + filename
    opens the file for reading.
  2. "ssi:w " + filename
    opens the file for overwriting.
  3. "ssi:a " + filename
    opens the file for appending.

Note that the filename may contain a path. An ssi file link can be used either for reading or for writing, but not for both at the same time. A close command must be used before a change of I/O direction.


Example:

 
  ring r;
  link l="ssi:w example.ssi"; // type=ssi, mode=overwrite
  l;
==> // type : ssi
==> // mode : w
==> // name : example.ssi
==> // open : no
==> // read : not open
==> // write: not open
  ideal i=x2,y2,z2;
  write (l,1, i, "hello world");// write three expressions
  write(l,4);                   // append one more expression
  close(l);                     // link is closed
  // open the file for reading now
  read(l);                      // only first expression is read
==> 1
  kill r;                       // no basering active now
  def i = read(l);              // second expression
  // notice that current ring was set, the name was assigned
  // automatically
  listvar(ring);
==> // ssiRing0                       [0]  *ring
==> // flint_poly_Q                   [0]  cring
==> // ZZ                             [0]  cring
==> // QQ                             [0]  cring
  def s = read(l);              // third expression
  listvar();
==> // s                              [0]  string hello world
==> // ssiRing0                       [0]  *ring
==> //      i                              [0]  ideal, 3 generator(s)
==> // l                              [0]  link
  close(l);                     // link is closed