dataFile( fname, list )

Creates a vertical pipe separated datafile from the supplied list-of-lists list. The datafile contents are written into the file according to the current output character encoding, see setCharSet for more details.

You can supply any MillScript object as the fname, but there are three points to consider:

  1. If the object is a URL object, the XML element e will be rendered to the file it specifies.
  2. If the object is not a URL, one will be created using the fname. If the fname contains a period, anything up to the last one will be considered the filename and anything after will be considered the extension. If the fname doesn't contain a period, the extension "html" will be appended automatically. e.g.
    :-) dataFile( "sample", { { "a value" } } );
    There are 0 results
    :-) dataFile( "sample.wml", { { "another value" } } );
    There are 0 results
              
  3. If the specified fname has already been created in the current MillScript instance, the filename will have an integer appended to it to make it unique. Please see the notes for the newURL function for more details.
:-) folder.addLast( "parent" );
There are 0 results
:-) dataFile(
:-)   "sample",
:-)   { { "value" } }
:-) );
There are 0 results
      
The specified list must be a list of lists. The outer list generates one line in the datafile per item in the list. Each line in the datafile is made of the items in the inner lists separated by a vertical pipe |. e.g.
:-) dataFile(
:-)   "datafile.db",
:-)   {
:-)     { "item 1", "item 2", "item 3" },
:-)     { "this", "is", "another", "list" }
:-)   }
:-) );
There are 0 results
      
would result in a datafile called datafile.db with the following contents:
item 1|item 2|item 3
this|is|another|list
      

Notes

If you use the same URL object multiple times, each successive use will replace the previously written file. See newURL for details.