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
1 |
rtename.SaveDocument ( filename {, filetype {, encoding }} ) |
Argument |
Description |
---|---|
rtename |
The name of the RichTextEdit control whose contents you |
filename |
A string whose value is the name of the file to be saved. |
filetype (optional) |
A value of the FileType enumerated datatype specifying the
|
encoding (optional) |
Character encoding of the file to which the data is saved. The filetype argument must be set to FileTypeText! If the
|
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:
1 2 3 |
integer li_rtn li_rtn = rte_1.SaveDocument("c: est.rtf", & FileTypeRichText!) |
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:
1 2 3 4 5 6 7 8 |
OpenWithParm( w_question, & "The specified file already exists. " + & "Do you want to overwrite it?" ) IF Message.StringParm = "Yes" THEN RETURN 0 // File is saved ELSE RETURN -1 // Saving is canceled END IF |
This code for a CommandButton saves the document in the RichTextEdit
rte_1 in a text file with UTF-16LE encoding:
1 2 3 |
integer li_rtn li_rtn = rte_1.SaveDocument("c: est.txt", & FileTypeText!, EncodingUTF16LE!) |
See also