| 4D v18WP New | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
 | 
    4D v18
 WP New 
         | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WP New {( source {; option} )} -> Function result | ||||||||
| Parameter | Type | Description | ||||||
| source | String, BLOB, Object |   | String: HTML source, BLOB: 4D Write Pro document (.4wp) or legacy 4D Write Blob document (.4w7/.4wt) Object: range or element or 4D Write Pro document | |||||
| option | Longint |   | Import option for HTML expressions | |||||
| Function result | Object |   | 4D Write Pro object | |||||
The WP New command creates and returns a 4D Write Pro object. The returned object is a complete document that can be passed to the WP INSERT DOCUMENT command, for example.
By default, if you omit the source parameter, the command returns an empty 4D Write Pro object.
If the source parameter is used, the new 4D Write Pro object will be filled with the contents of the source. You can pass:
By defaut, HTML expressions inserted in legacy 4D Write documents are not imported (no 4D Write Pro support). If you pass the wk import html expressions as text constant in the option parameter, HTML expressions will be imported as raw text within ##htmlBegin## and ##htmlEnd## tags -- which will require formatting actions afterwards. For example:
##htmlBegin##<span>Imported title<b>bold</b></span>##htmlEnd##You want to create an empty 4D Write Pro object:
 myWPObject:=WP NewYou want to create a new 4D Write Pro object using a 4D Write Pro document stored on disk:
 C_BLOB($BlobDoc)
 C_OBJECT(myWPArea)
 DOCUMENT TO BLOB("myDoc.4wp";$BlobDoc) //load the document in a Blob
 myWPArea:=WP New($BlobDoc)You want to create a 4D Write Pro object containing a simple 4D expression reference:
 C_TEXT(myText)
 myText:="Today is "
 ST INSERT EXPRESSION(myText;"string(current date;System date long)";ST End text)
 myWPA:=WP New(myText)You want to initialize your Write Pro area with a previously-created template:
  //Export template from an existing area
 C_TEXT(wpTemplate)
 WP EXPORT VARIABLE(myWPArea;wpTemplate;wk web page html 4D)
 
  // use the template for a new area
 C_OBJECT(myNewWPA)
 myNewWPA:=WP New(wpTemplate)You want to import a document stored in a BLOB field of the current record from the former 4D Write plug-in into a new 4D Write Pro area, and keep HTML expressions:
 C_OBJECT(wpArea)
 wpArea=WP New([Templates]Reference_;wk import html expressions as text)You have defined a template document with different preformatted parts, each of them being stored as a bookmark. When producing a final document from the template, you can extract any bookmark as a new document and insert it in the final document. 
 
 ARRAY TEXT($_BookmarkNames;0)
 WP GET BOOKMARKS([TEMPLATES]WP;$_BookmarkNames) //get the bookmarks from the template
 $targetRange:=WP New //create an empty document (will be the final document)
 
 $p:=Find in array($_BookmarkNames;"Main_Header") //handle the main header part
 If($p>0)
    $Range:=WP Get bookmark range(WParea;$_BookmarkNames{$p}) //select the range
    $RangeDoc:=WP New($Range) //create a new document from the range
    WP INSERT DOCUMENT($targetRange;$RangeDoc;wk append+wk freeze expressions) //wk append=after replacement, $targetRange is equal to end of replaced text
 End if
	Product:  4D
	Theme:  4D Write Pro Language
	Number:  
        1317
        
        
        
	
	Created:  4D v14 R5
	Modified:  4D v15 R2
	Modified:  4D v16
	Modified:  4D v16 R5
	Modified:  4D v17 R5
	4D Write Pro Reference ( 4D v18)
	
	
	
 Add a comment
Add a comment