Difference between revisions of "WriteTextFile"

(CurrentDataDirectory is now CurrentDataFolder EW 14658)
Line 5: Line 5:
 
[[What's new in Analytica 4.0?]] >
 
[[What's new in Analytica 4.0?]] >
  
= WriteTextFile( filename, text'', append, warn, sep, showDialog, encoding'' ) =
+
== WriteTextFile(filename, text'', append, warn, sep, showDialog, encoding'') ==
  
Writes text to a file with name filename.
+
Writes text to a file with name «filename».
  
If the file exists, and append is true, it appends the text to the file. If it doesn't exist, it asks whether to create it.
+
If the file exists, and «append» is <code>True</code>, it appends the text to the end of the file. If it doesn't exist, it asks whether to create it. If «append» is <code>False</code>, and the file exists, if «warn» is <code>True</code>, it gives a warning to ask if you want to overwrite the file. Setting «warn» to <code>False</code>, suppresses the warning about the file already existing.
If append is false, and the file exists, if warn is true, it gives a warning to ask if you want to overwrite the file.
 
If
 
  
(new to 4.0) The optional «showDialog» flag controls whether the file dialog displays.  If not specified, then the dialog appears if the indicated filename is a folder, a read-only file, or if it exists and warn is true.  When «showDialog» is true, the dialog displays, using the indicated filename as a default value but allowing the user to change it.  When false, the dialog is suppressed in all cases (usually meaning an error is issued instead).
+
The optional «showDialog» flag controls whether the file dialog displays.  If not specified, then the dialog appears if the indicated filename is a folder, a read-only file, or if it exists and «warn» is <code>True</code>.  When «showDialog» parameter is <code>True</code>,  it always opens a dialog before creating the file, so user can change file name and select folder -- the dialog displays, using the indicated filename as a default value but allowing the user to change it.  When <code>False</code>, the dialog is suppressed in all cases (usually meaning an error is issued instead).
  
Setting «append» to true appends to the end of an existing file.
+
[[WriteTextFile]] uses «sep» as a line separator between elements when «text» is an array.  
  
Setting «warn» to false suppresses the warning about the file already existing.
+
(new to [[Analytica 4.5|4.5]]) «encoding» parameter specifies the character encoding. Possible values are:
 
+
* <code>"ANSI"</code> : One byte per character, [http://en.wikipedia.org/wiki/8859 ISO-8859-1]. Extended characters (above ascii 255) are written as ?.
It uses «sep» as a line separator between elements when «text» is an array.
+
* <code>"UTF-8"</code> : [http://en.wikipedia.org/wiki/UTF-8 UTF-8 encoding] with a [http://en.wikipedia.org/wiki/Byte_order_mark byte order mark] ([http://en.wikipedia.org/wiki/Byte_order_mark BOM]). The UTF-8 encoding uses one byte for comman characters, and 2-3 bytes for characters with ascii values above 127.
 
+
*<code> "-UTF-8"</code> : [http://en.wikipedia.org/wiki/UTF-8 UTF-8 encoding] without a BOM.
If «showdialog» is true, it always opens a dialog before creating the file, so user can change file name and select folder. If false, it suppresses the dialog in all cases.
+
* <code>"UTF-16"</code> : Two bytes per character, big endian, with BOM.
 
+
* <code>"UTF-16le"</code> : Two bytes per character, little endian, with BOM.
(new to [[Analytica 4.5|4.5]]) «Encoding» specifies the character encoding. Possible values are:
 
* "ANSI" : One byte per character, [http://en.wikipedia.org/wiki/8859 ISO-8859-1]. Extended characters (above ascii 255) are written as ?.
 
* "UTF-8" : [http://en.wikipedia.org/wiki/UTF-8 UTF-8 encoding] with a [http://en.wikipedia.org/wiki/Byte_order_mark byte order mark] ([http://en.wikipedia.org/wiki/Byte_order_mark BOM]). The UTF-8 encoding uses one byte for comman characters, and 2-3 bytes for characters with ascii values above 127.
 
* "-UTF-8" : [http://en.wikipedia.org/wiki/UTF-8 UTF-8 encoding] without a BOM.
 
* "UTF-16" : Two bytes per character, big endian, with BOM.
 
* "UTF-16le" : Two bytes per character, little endian, with BOM.
 
 
 
= See also =
 
  
 +
== See also ==
 
* [[ReadTextFile]]
 
* [[ReadTextFile]]
 
* [[CurrentDataFolder]]
 
* [[CurrentDataFolder]]

Revision as of 04:54, 14 January 2016


What's new in Analytica 4.0? >

WriteTextFile(filename, text, append, warn, sep, showDialog, encoding)

Writes text to a file with name «filename».

If the file exists, and «append» is True, it appends the text to the end of the file. If it doesn't exist, it asks whether to create it. If «append» is False, and the file exists, if «warn» is True, it gives a warning to ask if you want to overwrite the file. Setting «warn» to False, suppresses the warning about the file already existing.

The optional «showDialog» flag controls whether the file dialog displays. If not specified, then the dialog appears if the indicated filename is a folder, a read-only file, or if it exists and «warn» is True. When «showDialog» parameter is True, it always opens a dialog before creating the file, so user can change file name and select folder -- the dialog displays, using the indicated filename as a default value but allowing the user to change it. When False, the dialog is suppressed in all cases (usually meaning an error is issued instead).

WriteTextFile uses «sep» as a line separator between elements when «text» is an array.

(new to 4.5) «encoding» parameter specifies the character encoding. Possible values are:

  • "ANSI" : One byte per character, ISO-8859-1. Extended characters (above ascii 255) are written as ?.
  • "UTF-8" : UTF-8 encoding with a byte order mark (BOM). The UTF-8 encoding uses one byte for comman characters, and 2-3 bytes for characters with ascii values above 127.
  • "-UTF-8" : UTF-8 encoding without a BOM.
  • "UTF-16" : Two bytes per character, big endian, with BOM.
  • "UTF-16le" : Two bytes per character, little endian, with BOM.

See also

Comments


You are not allowed to post comments.