Understanding the File_Field and Field Keywords

In DataFlex, a file-number identifies tables and a Field number identifies a table-column. Data Dictionaries use the same system: A Data Dictionary’s Table is identified by a File Number (Main_File), and each of its fields is identified by a Field Number.

This has the advantage the tables and fields can be represented in an abstract manner. The entire DataDictionary class is created using this abstraction. This allows you to create classes (perhaps a custom sub-class of the DataDictionary class) that also allows for this abstraction. For example, you could create a custom method that returns a field’s long label with all spaces removed. In addition, if the data type of the field is numeric it will place a “$” at the end of the label:

Class cMyDataDictionary is a DataDictionary

    Function Field_NoSpaceLabel Integer iField returns string

        String  sLabel

        Integer iFile iFieldType

        Get Main_File to iFile

        Get_Attribute DF_FIELD_TYPE of iFile iField to iFieldType

        Get Field_Label iField DD_LABEL_LONG to sLabel


        Move (Replaces(" ", sLabel, "")) to sLabel


        If (iFieldType = DF_BCD) begin

            Move (sLabel + "$") to sLabel


        Function_Return sLabel



This class will now work properly with any Data Dictionary using any table and any field.

While the use of file and field numbers is very useful for creating abstracted processing it becomes more cumbersome when you wish to use these interfaces in a non-abstract manner (i.e., using them when you know the names of the table and fields but you don’t know their numbers). You don’t want to have to keep track of numbers; you want to use meaningful names.

Symbols, commands and special command syntax are provided to make this easy.

See Also

The TableName.File_Number Symbol

The Field Keyword

The File_Field Keyword

File versus File_Field