3.3.6 Code Fragment
The code fragment virtual field allows you to specify RDMLX code to populate a virtual field when reading from a file, and to populate a real field when writing to a file.
A code fragment does not support the full range of RDML/X commands. In Version 11, you are limited to constructs such as If, Case, Dountil, Dowhile, Change, Assign.
At execution time, the code fragment will have read-only access to all fields in the file. You may use trigger functions for complex coding of virtual fields or to update fields in a file.
Code Fragments are specified by selecting
in the dropdown list in the tab. In the tab, when you select the option, the associated tab for is displayed. Enter the code fragment to be used to derive the virtual field. The code fragment is typically derived from one or more real fields on the file but may also use system variables, multilingual variables and work fields.When you select the
option, the associated tab for is displayed. Enter the code fragment to be used to derive the real field values. The code fragment is typically derived from the current virtual field.In the following example, only the first option is selected, so only the
tab is shown:
When both options are selected both tabs appear:
When only the second option is selected, only the
tab is shown:
Code fragment vs concatenation
Code fragments give you more control and variability than concatenation. The following example of Concatenation uses the same information to derive the real and the virtual field (simply by applying reverse of definition) and gives you a similar but not quite the same result.
The code fragment:
#fullname := #surname + ' , ' + #givename
would result in Turner , Scott
Concatenation of Surname and Full name would give TurnerScott
Also see
Code Fragment Virtual Field Derivation