4D v17

WP SET TEXT

Home

 
4D v17
WP SET TEXT

WP SET TEXT 


 

WP SET TEXT ( wpRange ; newText ; textPosition {; rangeUpdate} )  
Parameter Type   Description
wpRange  Object in Range object
newText  Text in Text to insert
textPosition  Number in Insertion position (replace, before, after)
rangeUpdate  Number in Includes or excludes the inserted content within the range

The WP SET TEXT command inserts the text passed in the newText parameter as plain text into a 4D Write Pro document at a specific position designated by the wpRange and textPosition parameters.

In the wpRange parameter, pass a range object to designate the position where text will be inserted. The range can be an explicit location in the 4D Write Pro document or it can be based on a user's selection.

The newText parameter contains the text to be inserted within wpRange. WP SET TEXT inserts plain text only, exactly as its written, but without any style tags.

In the textPosition parameter, the location of the inserted text can be specified by passing one of the following selectors:

Constant Comment
wk append Insert contents at end of target
wk prepend Insert contents at beginning of target
wk replace Replace target contents

In the optional rangeUpdate parameter, you can pass one of the following constants to specify whether or not the inserted contents are included in the resulting range:

Constant Comment
wk exclude from range Inserted contents not included in updated range
wk include in range Inserted contents included in updated range (default)

Example  

You want to add text to this document:

Before the existing text:

 $range:=WP Create range(myDoc;wk start text;wk end text)
 WP SET TEXT($range;" Hello world!";wk prepend)
  //writes " Hello world! The quick brown fox jumps over the lazy dog."

After the existing text:

 $range:=WP Create range(myDoc;wk start text;wk end text)
 WP SET TEXT($range;" Hello world!";wk append)
  //writes "The quick brown fox jumps over the lazy dog. Hello world!"

Replace the existing text:

 $range:=WP Create range(myDoc;wk start text;wk end text)
 WP SET TEXT($range;" Hello world!";wk replace)
  //writes " Hello world!"



See also 

WP Get text

 
PROPERTIES 

Product: 4D
Theme: 4D Write Pro Language
Number: 1574

This command can be run in preemptive processes

 
HISTORY 

New
Created: 4D v17

 
ARTICLE USAGE

4D Write Pro Reference ( 4D v17)