Skip to content

Programming Styles

Two programming styles can be used to handle tables in a DataFlex program: RowId style and RECNUM style.

  • RowId style can be used with both table types.
  • RECNUM style can only be used with recnum tables. Trying to use the RECNUM style with standard tables will result in errors.

RowId Style

If the RowId programming style is used, the RowId helper functions are utilized to manipulate tables. Please note that you can use the RowId programming style on both standard and recnum tables. The RowId programming style is the recommended style.

RECNUM Style

If the RECNUM programming style is used, the record number column can be accessed as if it exists. The DataFlex programmer can manipulate the RECNUM column like any other column, except for its value when creating a record. A common technique is to store the record number, perform some operations, re-find the record, and manipulate the buffer. This is done by:

Move MyTable.Recnum To LocalVariableMove LocalVariable To MyTable.Recnum
Find Eq MyTable By Recnum

The above code will still work when using the drivers with recnum tables. The driver will automatically translate every reference to RECNUM into a reference to the record identity column.

DataFlex handles moving a value into the record number column in a special way. In addition to moving the value into the (logical) column, the record buffer’s status is set to INACTIVE. This feature is used to create copies of existing records.

Drivers fully support this behavior. For example, if we have a table called MyTable, with a record identity column called MyRID, the following two commands will place 10 into the MyRID column:

Move 10 To MyTable.Recnum
Move 10 To MyTable.MyRID

The first command will also set the MyTable record buffer to inactive. The second command will not change the status of the record buffer.

Please note that if a table has a hidden record identity, there is only one way to access that column: Table.Recnum. If a table has a visible record identity, there are two ways to access the column: Table.Recnum and Table.RecId.

See Also