Table of Contents
This chapter gives an overview of FDL (Field Definition Language).
Effective data transmission across different platforms depends entirely on the data type and length, which can vary due to the memory allocation methods used by each platform. Even if the same data type is used, the resulting data values may differ between platforms. Data can be made compatible across different platforms by using a converted data value from the STRING data type. Although network performance can suffer due to heavier data loads, the Tmax system provides the Field Definition Language (FDL) method in an effort to provide the ultimate solution to these data communication problems.
The Field Definition Language (FDL) is a set of C language functions for defining and manipulating storage structures called field buffers.
A field buffer contains a set of attribute-value pairs in a field: an identifier (field key) and its data value. The identifier-value pair enables parameterized interaction between FDL and data in different kinds of processes. The identifier is used and referenced when data is passed between processes. However, when data processing is required, the data value mapped to the identifier is called and used.
The following describes the major terms used in this guide:
There are many ways to represent a record. The following compares a C language structure with a field buffer.
The following is an example of a C language data structure that contains the ID, name, address, age, and gender information of a student:
struct student { long stid; char name[10]; char addr[40]; short age; char sex; } ;
The structure has five fields: stid, name, addr, age, and sex. Following each field is its declared data type: stid is a long type; name and addr are char types; age is a short type; and sex is a char type.
A variable named 'x' points to the student structure. 'x' allows the structure to be available for the address of a field.
x→stid, x→name, x→addr, x→age, x→sex
To pass a structure to another process, data from each field is sent even if a field is unused. A C language type structure has two disadvantages.
Each time a data structure is modified, all programs using the structure must be recompiled.
The size of a structure and the offsets of component fields are fixed, which can result in wasted space, since fields do not always contain a value, and fields tend to be sized to hold the largest likely entry.
A field buffer is a data structure that provides an alternative method for dividing records into fields. Unlike C structures, field buffers are a data structure that divides a record into fields and relates the fields. A field name is a field key that points to actual data and its type. The name can be up to 16 characters in length.
The main advantage of the field buffer is data independence. Data independence allows the field type and length to be modified without requiring recompilation of the programs that use these fields. Unlike a C language data structure, which passes all member values, the field key method is able to pass only the fields and values that are in use.
To create a field table, use the fdlc utility with a text file that contains the relevant data.
The following is a sample of a user-defined <demo.f> file. The file contains field types and unique numbers. Only this format can be applied to user-defined files.
# name | number | type | flags | comments |
---|---|---|---|---|
*base | 100 | |||
INPUT | 101 | string | - | - |
OUTPUT | 102 | string | - | - |
SEQNO | 201 | string | - | - |
CORPNO | 202 | string | - | - |
COMPDATE | 203 | string | - | - |
TOTMON | 204 | long | - | - |
GUARAT | 205 | float | - | - |
GUAMON | 206 | float | - | - |
T_BITMAP | 900 | carray | - | - |
FILENAME | 901 | string | - | - |
NEWFILE | 902 | string | - | - |
*base | 1000 | |||
data1 | 301 | long | - | - |
data2 | 302 | long | - | - |
data3 | 303 | long | - | - |
sumdata | 304 | long | - | - |
data4 | 305 | long | - | - |
'name', 'number', and 'type' must be defined in order to use this field table.
Field value | Description |
---|---|
name | A field name with a maximum length of 48 characters. name is set to the field key, which is extracted from the field buffer as a parameter of fbget_fldkey. |
number | The relative numeric value of a field. The combination of a number and a type make up a field identifier. Each number must be unique in a field table because the type cannot be unique. In <demo.f>, a "*base number" is a base for offsetting the numbers listed after *base. A *base number' is actually the same as a 'INPUT number' and is written as 101. This base is valid until another base is declared. |
type | A field type. Eight field types are available: char, short, int, long, float, double, string, and carray. |
fdlc is a utility used for compiling a field key table. The FDL method only passes necessary items instead of all items in a structure as it does during data communication between a client and a server. A unique key is needed to distinguish each item. fdlc creates a field key by compiling a field key table defined in a text format.
How to use
$ fdlc ( -c ) {- a|c|d|u} [-f] [-h header file name] { -i field key table file name } [-jc|ji] [-o output name] [-u] [-p pacage name] [-x] [-V]
Item | Description |
---|---|
[ -a ] | Compiles a field key table from text into a binary file and adds required parts. Use the [-f] option to specify a target file. The default target file is tmax.fdl. Existing fields are overwritten by new values. |
[ -c ] | Compiles a field key table into a binary file. Any existing binary file with the same name is overwritten. This option is the default setting. |
[ -d ] | Compiles a field key table into a binary file and deletes required parts. Use the [-f] option to specify a target file. The default target file is tmax.fdl. |
[ -u ] | Compiles a field key table into a binary file and modifies or adds required parts. Use the [-f] option to specify a target file. The default target file is tmax.fdl. |
[ -f ] | Specifies a target file to add, modify, and remove data in a text field key table. |
[ -h header file name ] | Modifies a header file name. If the [ -h ] option is not specified, the default FD header file name, 'field key table name_fdl.h', will be used. |
{ -i field key table file name } | Specifies a field key table file to be used in a client or server program. This option is required and a path can be specified. |
[ -ji|jc ] | Used in WebT to specify the format of a field definition class to be created. - ji: Creates a field definition class file in the interface format. - jc: Creates a field definition Java file in the class format. |
[ -o output name ] | Modifies an output binary file name. If the [ -o ] option is not specified, the output binary file will be named tmax.fdl. |
[ -p package name ] | Used in WebT to set the package name of a created field definition class. |
[ -x ] | Keeps the original value of duplicate fields. This option must be used with the [-a] option. |
[ -V ] | Displays the version of an executable file. |
The following is an example of creating a Java file with the { -ji|jc } option.
<demo.f>
#demo.f #name number type flags comments INPUT 101 string - - OUTPUT 102 string - -
$> fdlc -c -i demo.f -ji -jc webtdemo
<demo_fdl.java>
package webtdemo; public interface demo_fdl { public int INPUT = (469762149); /* number: 101 type: string */ public int OUTPUT = (469762150); /* number: 102 type: string */ }
The following command compiles the <demo.f> field key table file in a current directory. <tmax.fdl> and <demo_fdl.h> are created after successful compilation. <demo_fdl.h> is a header file that defines the field key.
$fdlc -c -i demo.f
To specify a name for a .fdl file, use the [-o] option as follows.
$fdlc -c -i demo.f -o filename.fdl
When a client and server use field buffers to communicate, the .fdl file that is output is referenced so that a required data type field can be used. When using a field buffer, the FDLFILE environment variable must be set to the path and name of the .fdl file. In the example below, FDLFILE points to <filename.fdl>.
FDLFILE=/home/tmax/sample/fdl/filename.fdl
1. When using a field table, verify that the field key is unique within the domain.
2. For more information about the fdlc utility, refer to "Tmax Reference Guide".