Tech Tip: Getting started with 4D Transition Tags
PRODUCT: 4D | VERSION: 14 R4 | PLATFORM: Mac & Win
Published On: March 16, 2015
New to 4D v14 R4 are 4D Transition Tags, they are new and enhanced additions to the 4D HTML Tags family. 4DEVAL is new and 4DLOOP is enhanced.
The new addition 4DEVAL is an inline interpreter. It assess a variable or a 4D expression and execute any valid 4D statement, including assignments and expressions that do not return any value. It's real power comes from its ability to take 4D commands or functions directly as expressions.
For example, in prior verisons of 4D, for 4D to advance to the next record a call had to be made to a 4D method to load the next record, see the code below. This method would also have to have to attribute "Available through 4D tags and URLs (4DACTION...)" set.
C_TEXT($0) // This parameter must always be declared C_TEXT($1) // This parameter must always be declared NEXT RECORD(Table_P->) |
With 4DEVAL three lines of 4D code can be replace with one line of code that calls a 4D command directly.
<!--#4DEVAL NEXT RECORD:C51(Table_P->) -->
The ":C51" is the command number escape code. The command number escape code is optional but is a good idea because it allows the expression will be correctly evaluated no matter which 4D language version is used. More examples are below, this time displaying the use of a pointer and local variable with a 4D command.
<!--#4DEVAL $RIS:=Records in selection:C76(Table_P->)-->
<!--#4DEVAL $SRN_L:=Selected record number:C246(Table_P->)-->
<!--#4DEVAL GOTO SELECTED RECORD:C245(Table_P->;$SRN_L)-->
There are two locations where this code can be found. One is in the design environment Commands section, as shown below...
and in the online documentation on the right side under the PROPERTIES banner, as shown below.
4DLOOP have been enhanced with the addition of two new abilities, accepting a 4D expression and pointer arrays. The code below shows 4DLOOP using a 4D expression.
<!--#4DLOOP ($Ndx<$RPP_L)--> <!--#4DEVAL GOTO SELECTED RECORD:C245(Table_P->;$SRN_L)--> <!--#4DSCRIPT/WEB_FillProcessVars--> <!-- DO SOME WORK --> <!--#4DEVAL $Ndx:=$Ndx+1--> <!--#4DEVAL $SRN_L:=$SRN_L+1--> <!--#4DENDLOOP--> |
The new ability to use local variables with 4D HTML tags enhances memory by reducing the number of process variables neeeded on 4D's stack.