SaveDocument – PB Docs 2017

SaveDocument

PowerScript function

Description

Saves the contents of a RichTextEdit control in a file. You can
specify either rich-text format (RTF) or text format for the file.

Applies to

RichTextEdit controls

Syntax

Argument

Description

rtename

The name of the RichTextEdit control whose contents you
want to save.

filename

A string whose value is the name of the file to be saved.
If the file already exists, the FileExists event is
triggered.

filetype 

(optional)

A value of the FileType enumerated datatype specifying the
format of the saved file. Values are:

  • FileTypeRichText! — Save the file in rich text
    format

  • FileTypeText! — Save the file as text

  • FileTypeDoc! — Save the file in Microsoft Word
    format

  • FileTypeHTML! — Save the file in HTML format

  • FileTypePDF! — Save the file in PDF format

encoding (optional)

Character encoding of the file to which the data is saved.
This parameter applies only to text files. If you do not specify
an encoding parameter, the file is saved in ANSI format.

The filetype argument must be set to FileTypeText! If the
filetype argument is set to any other file type, this argument
is ignored. Values are:

  • EncodingANSI! (default)

  • EncodingUTF8!

  • EncodingUTF16LE!

  • EncodingUTF16BE!

Return value

Integer.

Returns 1 if it succeeds and -1 if an error occurs.

Usage

SaveDocument triggers a FileExists event when the file you name
already exists. If you do not specify a filetype, SaveDocument saves the
file as a text file if you specify a file name with the extension .txt, as
a Microsoft Word document if you specify a file name with the extension
.doc, and as an RTF file if you specify a file name with the .rtf
extension.

The format that you specify in the encoding argument is valid only
if you specified FileTypeText! for the filetype argument.
SaveDocument saves text in ANSI format only for all other file
types.

Examples

This code for a CommandButton saves the document in the RichTextEdit
rte_1:

If the file TEST.RTF already exists, PowerBuilder triggers the
FileExists event with the following script. OpenWithParm displays a
response window that asks the user if it is OK to overwrite the file. The
return value from FileExists determines whether the file is saved:

This code for a CommandButton saves the document in the RichTextEdit
rte_1 in a text file with UTF-16LE encoding:

See also

InsertDocument


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x