4D v16.3

PROCESS 4D TAGS

Home

 
4D v16.3
PROCESS 4D TAGS

PROCESS 4D TAGS 


 

PROCESS 4D TAGS ( inputTemplate ; outputResult {; param}{; param2 ; ... ; paramN} ) 
Parameter Type   Description
inputTemplate  Text, BLOB in Data containing tags to process
outputResult  Text, BLOB in Result from template execution
param  Text, Number, Date, Time, Pointer, Boolean in Parameter(s) passed to template being executed

The PROCESS 4D TAGS command causes the processing of 4D transformation tags contained in the inputTemplate parameter (field or variable of the BLOB or Text type) while (optionally) inserting value(s) using the param parameters and returns the result in outputResult. For a complete description of these tags, refer to the 4D Transformation Tags section.

This command lets you execute a "template" type text containing tags and references to 4D expressions and/or variables, and to produce a result depending on the execution context and/or the values passed as parameters.
For example, you can use this command to generate and save HTML pages based on semi-dynamic pages containing 4D transformation tags (without it being necessary for 4D's Web server to be started). You can use it to send e-mail messages in HTML format that contain processing of and/or references to data contained in the database via the 4D Internet Commands. It is possible to process any type of data based on text, such as XML, SVG or multi-style text.

Pass the data containing the tags to be processed in the inputTemplate parameter. This parameter can be a field or variable of the BLOB or Text type. The Text type is usually sufficient (parameters can receive up to 2 GB of text).

Compatibility note: Beginning with version 12 of 4D, when you use BLOB type parameters, the command automatically considers that the character set used for BLOBs is MacRoman. For better efficiency, it is strongly recommended to use Text type parameters for which processing is carried out in Unicode mode.

All the transformation tags of 4D are supported (4DTEXT, 4DHTML, 4DSCRIPT, 4DLOOP, 4DEVAL, etc.).

Note: When using the 4DINCLUDE tag outside the framework of the Web server (Web process):

  • with 4D in local mode or 4D Server, the default folder is the folder containing the database structure file,
  • with 4D in remote mode, the default folder is the folder containing the 4D application.

The PROCESS 4D TAGS command supports an indefinite number of param parameters that can be inserted into the executed code. As with project methods, these parameters can contain scalar values of varied types (text, date, time, longint, real, etc.). You can also use arrays, by means of array pointers. Inside the code processed by the 4D tags, these parameters can be accessed by means of standard arguments ($1, $2, etc.), just like in 4D methods 4D (see example).
A dedicated set of local variables is defined in the execution context of the PROCESS 4D TAGS command. These variables can be written or read during processing.

Compatibility note: In previous versions of 4D, local variables defined in the calling context could be accessed in the PROCESS 4D TAGS execution context in interpreted mode. Beginning with 4D v14 R4, this is not the case anymore.

After command execution, the outputResult parameter receives the execution result of the inputTemplate parameter, along with the result of the processing of any 4D tags that it contains, when applicable. If inputTemplate does not contain any 4D tags, the contents of outputResult is identical to that of inputTemplate.
The outputResult parameter may be a field or a variable, but it must be of the same type as that of the inputTemplate parameter.

Note: This command never calls the On Web Authentication database method.

This example loads a 'template' type document, processes the tags it contains and then stores it:

 C_BLOB($Blob_x)
 C_BLOB($blob_out)
 C_TEXT($inputText_t)
 C_TEXT($outputText_t)
 
 DOCUMENT TO BLOB("mytemplate.txt";$Blob_x)
 $inputText_t:=BLOB to text($Blob_x;UTF8 text without length)
 PROCESS 4D TAGS($inputText_t;$outputText_t)
 TEXT TO BLOB($outputText_t;$blob_out;UTF8 text without length)
 BLOB TO DOCUMENT($document;$blob_out)

This example generates a text using data of the arrays:

 ARRAY TEXT($array;2)
 $array{1}:="hello"
 $array{2}:="world"
 $input:="<!--#4DEVAL $1-->"
 $input:=$input+"<!--#4DLOOP $2-->"
 $input:=$input+"<!--#4DEVAL $2->{$2->}--> "
 $input:=$input+"<!--#4DENDLOOP-->"
 PROCESS 4D TAGS($input;$output;"elements = ";->$array)
  // $output = "elements = hello world"



See also 

4D Transformation Tags

 
PROPERTIES 

Product: 4D
Theme: Tools
Number: 816

This command can be run in preemptive processesDifferent in remote mode

 
HISTORY 

Created: 4D 2004
Modified: 4D v11 SQL
Modified: 4D v12
Renamed: 4D v13
Modified: 4D v14 R4

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)