Originally introduced in 4D v14 R4
The 4D transformation tags (previously named 4D HTML tags) have been extended:
- A new 4DEVAL tag has been added,
- The 4DLOOP tag now supports any 4D expression or a pointer to an array as parameter.
Note: The PROCESS 4D TAGS command has also been extended. For more information, please refer to the PROCESS 4D TAGS section.
Syntax: <!--#4DEVAL VarName--> or <!--#4DEVAL 4DExpression-->
The new 4DEVAL tag allows you to assess a variable or a 4D expression.
Like the existing 4DHTML tag, 4DEVAL does not escape HTML characters when returning text. However, unlike 4DHTML or 4DTEXT, 4DEVAL allows you to execute any valid 4D statement, including assignments and expressions that do not return any value.
For example, you can execute:
$input:="<!--#4DEVAL a:=42-->"
$input:=$input+"<!--#4DEVAL a+1-->"
PROCESS 4D TAGS($input;$output)
You can use 4D commands or functions directly as expressions. In this case, it is a good idea to insert the command number escape code in the 4DExpression parameter. This way the expression will be correctly evaluated no matter which 4D language version is used, or if the command name changes in a future 4D release. The syntax to use is "<command_name>:C<command_number>. For example, to call Current time, write "Current time:C178".
Note: Command numbers can be found on the Commands page of the Explorer:

In case of an evaluation error, the text inserted will be in the form: “<!--#4DEVAL expression--> : ## error # error code”.
Note: Executing a 4D method with 4DEVAL from a Web request requires that the "Available through 4D tags and URLs (4DACTION...)" option is set in the Method properties. For more information about this, refer to the Connection Security section.
The 4DLOOP tag now accepts two new kinds of conditions (besides table, array and method): a 4D expression and a pointer array.
- <!--#4DLOOP 4DExpression-->
With this syntax, the 4DLOOP tag will make a loop as long as the 4D expression returns True. The expression can be any valid Boolean expression and must contain a variable part to be evaluated in each loop to avoid infinite loops.
For example, the following code:
<!--#4DEVAL $i:=0-->
<!--#4DLOOP ($i<4)-->
<!--#4DEVAL $i-->
<!--#4DEVAL $i:=$i+1-->
<!--#4DENDLOOP-->
will produce:
0
1
2
3
- <!--#4DLOOP pointerArray-->
In this case, the 4DLOOP tag will work like it does with an array: it makes a loop for each array element. The current array element is increased each time the portion of code is repeated.
This syntax is useful when you pass an array pointer as a parameter to the PROCESS 4D TAGS command.
Example:
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)