4D v16

WP EXPORT VARIABLE

Home

 
4D v16
WP EXPORT VARIABLE

WP EXPORT VARIABLE 


 

WP EXPORT VARIABLE ( wpDoc ; destination ; format {; option} )  
Parameter Type   Description
wpDoc  Object in 4D Write Pro variable
destination  Text variable, BLOB variable in Variable to receive exported contents
format  Longint in Variable output format
option  Longint, String in Export options

The WP EXPORT VARIABLE command exports the wpDoc 4D Write Pro object to the 4D destination variable in the specified format.

In wpDoc, pass the 4D Write Pro object that you want to export.

In destination, pass the variable that you want to fill with the exported 4D Write Pro object. The type of this variable depends on the export format specified in the format parameter:

  • If you pass the native .4wp format, the variable will be of the Blob type,
  • If you pass an HTML format, the variable will be of the Text type.

In the format parameter, pass a constant from the 4D Write Pro Constants theme to set the export format you want to use. Each format is related to a specific use. The following formats are supported:

Constant Type Value Comment
wk 4wp Longint 4 The 4D Write Pro document is saved in a native archive format (zipped HTML and images saved in a separate folder). 4D specific tags are included and 4D expressions are not computed. This format is particularly suitable for saving and archiving 4D Write Pro documents on disk without any loss.
wk mime html Longint 1 4D Write Pro document is saved as standard MIME HTML with HTML documents and images embedded as MIME parts (encoded in base64). Expressions are computed and 4D specific tags are removed. This format is particularly suitable for sending HTML emails with the SMTP_QuickSend command.
wk web page html 4D Longint 3 4D Write Pro document is saved as HTML and includes 4D specific tags; each expression is inserted as a non-breaking space. Since this format is lossless, it is appropriate for storing purposes in a text field.

Notes:

  • "4D specific tags" means 4D XHTML with a 4D namespace and 4D CSS styles.
  • Expressions can be frozen at any time before export using ST FREEZE EXPRESSIONS.
  • For more information about the 4D Write Pro document format, refer to .4wp document format.

In the options parameter, you pass options that will configure the export. You can pass either:

  • a longint value to define the style of the HTML code; the following constants are available:
     
    Constant Type Value Comment
    wk html debug Longint 1 Formatted HTML code ("pretty print"), easier to debug
    wk normal Longint 0 Standard HTML code


    • HTML debug option off (default):

       

    • HTML debug option on:

       
  • or a string. The following property is supported (only when the wk mime html format is used):
    • CID host domain name: host domain that will added to generated CID URLs including an '@' as separator. For instance, if you pass "gmail.com", '123@gmail.com' will be inserted if the CID unique ID is 123. By default if omitted, only the CID unique ID is used (accepted by most mail servers).

Example  

You want to send an email containing styled text, 4D references and images. You can use a 4D Write Pro area exported in MIME HTML format and sent using 4D Internet Commands:

 C_LONGINT($smtpid_l;$err_l;$smtpOption_l;$smtpPort_l)
 C_TEXT($str;$emailBody_t;$smtpHost_t;$emailTo_t;$emailFrom_t;$smtpPass_t)
 
  //export area in appropriate format
 WP EXPORT VARIABLE(myWPArea;$str;wk mime html)
 $emailTo_t:="johnsmith@4d.com"
 $emailFrom_t:="testWritePro@gmail.com"
 $emailBody_t:=$str
 $smtpHost_t:="smtp.gmail.com"
 $smtpOption_l:=9
 $smtpPort_l:=465
 $smtpPass_t:="QRN_on_bretzelburg"
 
 $err_l:=SMTP_QuickSend($smtpHost_t;$emailFrom_t;$emailTo_t;$emailTitle_t;\
 $emailBody_t;$smtpOption_l;$smtpPort_l;$smtpUser_t;$smtpPass_t)
 
 If(($err_l=0))
    ALERT("Email sent to "+emailTo_t)
 Else
    ALERT("Error in parameters, please try again.")
 End if



See also 

WP EXPORT DOCUMENT

 
PROPERTIES 

Product: 4D
Theme: 4D Write Pro Language

This command can be run in preemptive processes

 
HISTORY 

Created: 4D v14 R5
Modified: 4D v15 R2

 
ARTICLE USAGE

4D Write Pro Reference ( 4D v16)