Skip to content

DF_FIELD_OFFSET

See Also

Obsolete

Overlap columns were replaced by multi-segment relationships in DataFlex 11.0 and are obsolete.

Description

The offset of the column in the record.

Level

Column

Supported by

All Drivers

Type

Numeric, permanent

Access

Read / Write

Values

1 ~ maximum record length

Remarks

DF_FIELD_OFFSET specifies the location of the beginning of the column in the record. It may only be set for Overlap columns. To define an overlap column, two attributes need to be set: DF_FIELD_OFFSET and DF_FIELD_LENGTH. DataFlex supports multi-segment relationships, which greatly reduces (or eliminates) the need for having overlap columns.

This is a permanent attribute that can only be set inside a Structure_Start ... Structure_End operation. For the DataFlex SQL Drivers, the permanent value of this attribute for overlap columns can be stored in the intermediate file using the Field_Overlap_Start or Field_Overlap_Offset_Start keywords.

Example: Show Offset

Procedure ShowOffset Handle hTable
    Integer iNumColumns
    Integer iOffset
    Integer iColumn
    String sTable
    String sColumn

    Get_Attribute DF_FILE_ROOT_NAME Of hTable To sTable
    Showln "The columns in table " sTable " have offsets:"
    Get_Attribute DF_FILE_NUMBER_FIELDS Of hTable To iNumColumns

    For iColumn From 1 To iNumColumns
        Get_Attribute DF_FIELD_NAME Of hTable iColumn To sColumn
        Get_Attribute DF_FIELD_OFFSET Of hTable iColumn To iOffset
        Showln (Right("        " + String(iOffset), 10)) ": " sColumn
    Loop
End_Procedure // ShowOffset
This example shows the offset for every column in the table.

Example: Add Overlap

Procedure AddOverlap Handle hTable Integer iStart Integer iEnd
    Integer iStartOffset
    Integer iEndOffset
    Integer iEndLength
    Integer iColumn

    Open hTable Mode DF_EXCLUSIVE
    Get_Attribute DF_FIELD_OFFSET Of hTable iStart To iStartOffset
    Get_Attribute DF_FIELD_OFFSET Of hTable iEnd To iEndOffset
    Get_Attribute DF_FIELD_NATIVE_LENGTH Of hTable iEnd To iEndLength
    Move (iEndOffset + iEndLength) To iEndOffset

    Structure_Start hTable
        Create_Field hTable At iColumn
        Set_Attribute DF_FIELD_NAME Of hTable iColumn To ("OVL_" - String(iStart) - "_" - String(iEnd))
        Set_Attribute DF_FIELD_TYPE Of hTable iColumn To DF_OVERLAP
        Set_Attribute DF_FIELD_OFFSET Of hTable iColumn To iStartOffset
        Set_Attribute DF_FIELD_LENGTH Of hTable iColumn To (iEndOffset - iStartOffset)
    Structure_End hTable
End_procedure // AddOverlap
This example creates an overlap field named OVL_X_Y (where X is the column number the overlaps start at and Y is the column number where the overlap ends) in the table.