InsertDocument

Description

Inserts a rich text format or plain text file into a DataWindow control or DataStore object.

The new content is added in one of two ways:

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataStore object

Syntax

PowerBuilder

integer dwcontrol.InsertDocument ( string filename, boolean clearflag, FileType filetype)

Argument

Description

dwcontrol

A reference to a DataWindow control or DataStore object. The DataWindow object in the DataWindow control or DataStore must be a RichTextEdit DataWindow.

filename

A string whose value is the name of the file you want to display in the RichTextEdit control. Filename can include the file’s path.

clearflag

A boolean value specifying whether the new file will replace the current contents of the control. Values are:

  • True – Replace the current contents with the file.

  • false – Insert the file into the existing contents at the insertion point.

filetype

A value of the FileType enumerated datatype specifying the type of file being opened. Values are:

  • FileTypeRichText! – (Default) The file being opened is in rich text format (RTF).

  • FileTypeText! – The file being opened is plain ASCII text (TXT).

  • FileTypeHTML! – The file being opened is in HTML format (HTM or HTML)

  • FileTypeDoc! – The file being opened is in Microsoft Word format (DOC)

Returns

Returns 1 if it succeeds and –1 if an error occurs. If any argument’s value is null, InsertDocument returns null.

Usage

When the control supports headers and footer (the HeaderFooter property is set to true), inserting a document can replace, but not add to, existing header and footer text. You must set clearflag to true to replace the existing header and footer text with header and footer text from the inserted document.

Not all RTF formatting is supported. PowerBuilder supports version 1.6 of the RTF standard, except for the following:

Any unsupported formatting is ignored.

NotePowerBuilder environment For use with other PowerBuilder RichTextEdit controls, see InsertDocument in the PowerScript Reference.

Examples

Example 1

This example inserts a document into a RichTextEdit DataWindow:

integer rtn

rtn = dw_1.InsertDocument("c:\pb\test.rtf", &

		false, FileTypeRichText!)

See also