SaveAsFormattedText method (DataWindows)
Description
Saves the contents of a DataWindow or DataStore into a standard
text file with custom formatting.
Controls
|
DataWindow type |
Method applies to |
|---|---|
|
PowerBuilder |
DataWindow control, DataStore object |
Syntax
[PowerBuilder]
|
1 |
long <span>dwcontrol</span>.<span>SaveAsFormattedText</span> ( string <span>filename</span> {, string <span>encoding</span> {, string <span>separatorcharacter</span> {,string <span>quotecharacter</span> {, string <span>lineending </span>{, boolean <span>retainnewlinechar</span> } } } } ) |
|
Argument |
Description |
|---|---|
|
dwcontrol |
A reference to a DataWindow control or |
|
filename |
A string whose value is the name of the |
|
encoding (optional) |
Character encoding of the file to which
|
|
separatorcharacter (optional) |
A string whose value is the character |
|
quotecharacter (optional) |
A string whose value is the character |
|
lineending |
A string whose value is placed at the |
|
retainnewlinechar (optional) |
A boolean value that determines whether
|
Return Values
Returns 1 if it succeeds and –1 if an error occurs.
Usage
SaveAsFormattedText is like SaveAs with
the Text SaveAsType. However, unlike SaveAs, SaveAsFormattedText formats
the text and saves column headers in the form in which they are
displayed in the DataWindow instead of as the column name. For example,
if the heading for the cust_id column is
Customer ID, SaveAsFormattedText saves Customer to the text file, whereas SaveAs saves
IDcust_id. SaveAsFormattedText also
saves computed fields allows you to customize formats in the file. If
you do not specify custom settings, values are wrapped in double
quotes and separated by tabs. A newline character (~r~n) is placed
at the end of each line. Line feed and carriage return characters
within each row are converted to white space.
PowerBuilder assigns a cell for each DataWindow object (which
can include computed columns and group totals). If a cell is empty, PowerBuilder
puts the quotecharacter between the separatorcharacter in the
output file.
Examples
This statement saves the contents of dw_Quarter
to the file H:Q2RESULTS.TXT.
The saved file uses UTF-16LE encoding with the ampersand (&)
as the separator character, single quote (')
as the character used to wrap values and the default line ending
(~r~n). Computed columns are included with the saved information:
|
1 |
dw_Quarter.<span>SaveAsFormattedText</span>("H:Q2RESULTS.TXT", EncodingUTF16LE!, "&", "'") |