Skip to content

New DD Methods

File_Field_Index

Type: Function
Arguments: integer iFile, integer iField
Returns: Integer

Get File_Field_Index of hDD iFile iField to iIndex
Get File_Field_Index of hDD File_Field FileName.FieldName to iIndex

This function retrieves the index for a file and field. If the DDO's ordering property is explicitly set (i.e., it is non-zero), that value will be returned. If it is not, the main index assigned to that file and field in Database Builder will be returned. If no index is assigned, -1 is returned.

This function operates by finding the DDO that "owns" the passed file and sending the message Field_Index to that object. Therefore, the message is actually resolved within Field_Index in the DDO that owns the file. For this reason, you should never augment File_Field_Index; augment Field_Index instead.

When sending this message, you can use either File_Field_Index or Field_Index. Using File_Field_Index is easier because you do not have to worry that the message is sent to the correct DDO—it will find the owner DDO and send the message Field_Index.

When augmenting this method, always augment Field_Index in the owner DD. You can now be sure that this method will get called.

The messages File_Field_Index and Field_Index were created to replace the now obsolete message Field_Main_Index.

Field_Index

Type: Function
Arguments: integer iFile, integer iField
Returns: Integer

Get Field_Index of hDD iField to iIndex
Get Field_Index of hDD File_Field FileName.FieldName to iIndex

Function Field_Main_Index integer iField returns integer
: // augment as needed
End_Function

This function retrieves the index for a field owned by this DDO. If the DDO's ordering property is explicitly set (i.e., it is non-zero), that value will be returned. If it is not, the main index assigned to that file and field in Database Builder will be returned. If no index is assigned, -1 is returned.

This function is usually called by File_Field_Index, which operates by finding the DDO that "owns" the passed file and sending the message Field_Index to that object. Therefore, the message is actually resolved within Field_Index in the DDO owner object. For this reason, you should never augment File_Field_Index; augment Field_Index instead.

When sending this message, you can use either File_Field_Index or Field_Index. Using File_Field_Index is easier because you do not have to worry that the message is sent to the correct DDO—it will find the owner DDO and send the message Field_Index.

When augmenting this method, always augment Field_Index in the owner DD. You can now be sure that this method will get called.

The messages File_Field_Index and Field_Index were created to replace the now obsolete message Field_Main_Index.

Field_Main_Index is now Obsolete

Prior to VDF8.2, the message Field_Main_Index was used by the DataDictionary and Data_set class to determine the main index for a passed file and field. This method had the drawback that the DDO (or DSO) receiving this message may not be the DDO that owns the file. For example, an Order DD may receive this message asking for the main index for a customer field (where Customer is the parent of Order). When this happens, the Order DD determines the main index for this customer without sending a message to the owner Customer DD. While this method works properly, it causes confusion when you want to augment this method. An augmentation in the parent DD (the owner of the field) will not get called.

It had been suggested that this be improved. We have implemented this improvement by adding the new messages File_Field_Index and Field_Index.

When sending this message, you can use either File_Field_Index or Field_Index. Using File_Field_Index is easier because you do not have to worry that the message is sent to the correct DDO—it will find the owner DDO and send the message Field_Index.

When augmenting this method, always augment Field_Index in the owner DD. You can now be sure that this method will get called.

The packages have all been changed so they no longer call Field_Main_Index. They now call File_Field_Index.

Important Compatibility Note

If you are using Field_Main_Index anywhere in your code, it will still work exactly as before. We strongly encourage you to bring your code up to date. You should search your code and make the following changes:

  1. Search for all occurrences where you call Field_Main_Index and change the name of the call to File_Field_Index.
  2. Search for any occurrences of augmentations of Field_Main_Index (look for function Field_Main_Index) and change it as follows:
// Old pre 8.2 code
function Field_Main_Index integer file integer field returns integer
// should be changed to
function Field_Index integer field returns integer

Notice the name change and the parameter change. Also, make sure that the function is located in the owner DDO.

We do not expect that many developers call Field_Main_Index, and we expect that even fewer developers have augmented this message. If you have augmented the message, you might have already encountered the limitation with Field_Main_Index, and we hope you will welcome this improvement!

Finally, if you are using data_sets instead of DDOs, no change is required. They continue to use the Field_Main_Index method. (Of course, you want to use DDOs.)

pbAutoFillFromFirst

Type: Property
Default: True

A new DDO property, pbAutoFillFromFirst, has been created that allows child DDOs to auto-fill from the last record. This can be used to great advantage and flexibility with the dbGrid/dbList properties Initial_column and pbReverseOrdering.

When a child DDO is related to a parent with a relates-to constraint, the auto_fill_state property of the child DDO determines what it should do when the parent record changes.

  • If auto_fill_state is set to false, the child DDO is cleared when the parent record changes.
  • If auto_fill_state is set to true, the first valid child is found.

Although auto_fill_state is a DD property, you usually don't need to set it explicitly in the DDO. DbGrids will automatically set their DDO's auto_fill_state to true. This is what makes child dbGrids work as they do. When the child DDO auto-finds the first record, it notifies the dbGrid that it has a new record. The dbGrid then fills in the rest of the records, and you see a populated grid.

The property pbAutoFillFromFirst allows you to determine if the auto-fill record should be the first valid record or the last valid record. The default value for this property is True. This means the first record will be found, which is how DataFlex has always worked. Setting this property to false will force the last record to be found.

This property is most useful when used with a child DDO that has a dbGrid attached to it. It can be used in conjunction with the dbGrid properties Initial_column and pbReverseOrdering (a new property added to 8.2).

For example, setting the DDO's pbAutoFillFromFirst to False and setting the dbGrid's Initial_column property to FILL_FROM_BOTTOM will cause the order entry sample to fill its detail grid from the last record located at the bottom of the grid.

Or, setting a dbGrid's pbReverseOrdering property to True and setting the DDO's pbAutoFillFromFirst property to False would display a grid with the last record presented in the first row and other records displayed in reverse order. This might be useful if your dbGrid is displaying dates, which you want displayed with the most recent date displayed first.

Remember that pbAutoFillFromFirst is set inside of the DD object. The properties Initial_column and pbReverseOrdering are set in the dbGrid (or dbList) object.

File_Field_Default_AutoFind

Type: Function
Arguments: integer iFile, integer iField

Send File_Field_Default_AutoFind of hDD iFile iField
Send File_Field_Default_AutoFind of hDD File_Field FileName.FieldName

This performs an autofind in "default" mode based on the passed file and field. This is similar to the file_field_autofind method except that it does not set the DDO's changed state to true. When a normal autofind is performed on a parent file (e.g., customer in order view), the main DD's changed-state is set to true because a new parent has been changed. A default autofind does not set this changed state, which avoids the generation of a data-loss warning. This function should be used to perform an autofind as part of setting defaults. It will often be used inside of a DDO's clear and clear_all method and will be used in conjunction with retained field values.

Adding the following code to the order view in the orderhea DDO will cause the customer key field to be retained and auto-found.

set file_field_option file_field customer.Customer_number to DD_Retain
// augment clear so that it performs an autofind for the customer. The 
// retained data will be used to perform this autofind 
procedure clear 
   forward send clear
   send File_Field_Default_AutoFind file_field customer.Customer_number
end_procedure

File_Field_Option

Type: Procedure set
Arguments: integer iFile, integer iField, integer iD_Option

Set File_Field_Option of hDD iFile iField to DD_Retain
Set File_Field_Option of hDD File_Field FileName.FieldName to DD_Retain

This is used to set a DD field option. This message was created so that DD option changes could be dynamic. Changes made to DD options will be immediately reflected by data-entry objects using this field.

This message is similar to the old DD message setFile_field_Options with two exceptions: 1. File_Field_Options accepts multiple parameters, and 2. File_Field_Options does not dynamically update DEOs with the option change.

File_field_Options (the old message) should only be used within the define_fields procedure, which are normally generated automatically for you by Database Builder.

If you need to set or change field options anywhere else within an application, you should use the message File_Field_Option, or the related messages File_Field_Option_Clear and File_Field_Option_Toggle.

The options that can be set in DataFlex are:

  • DD_AutoFind
  • DD_AutoFind_GE
  • DD_CapsLock
  • DD_DisplayOnly
  • DD_FindReq
  • DD_ForcePut
  • DD_NoEnter
  • DD_NoPut
  • DD_Required
  • DD_Retain
  • DD_Retain_All
  • DD_SkipFound
  • DD_Zero_Suppress

Normally, you will only set single options with this message. If you wish to set multiple options, you can IOR these options within an expression.

Set File_Field_Option of hDD iFile iField to (DD_Retain IOR DD_NoEnter)

Currently, a DD_Capslock is not immediately reflected in all objects—the object has to be deactivated and reactivated for the Capslock to take effect.

Use Field_Option instead of File_Field_Option if you are sure the message is being sent directly to the DD that owns the field. Often, you will find that within a DDO, you need to set options for parent or child DDOs. In this case, you must use the File_Field version of this message. Our advice is that you always use the file_field version of DD messages (e.g., file_field_option, file_field_option_clear, file_field_option_toggle) as this makes it simpler for you.

Field_Option

Type: Procedure set
Arguments: integer iField, integer iD_Option

See: File_Field_Option

File_Field_Option_Clear

Type: Procedure set
Arguments: integer iFile, integer iField, integer eDD_Option

Set File_Field_Option_Clear of hDD iFile iField to DD_Retain
Set File_Field_Option_Clear of hDD File_Field FileName.FieldName to DD_Retain

See: File_field_Option for more information.

Field_Option_Clear

Type: Procedure set
Arguments: integer iField, integer iD_Option

See: File_Field_Option_Clear

File_Field_Option_Toggle

Type: Procedure set
Arguments: integer iFile, integer iField, integer eDD_Option

Set File_Field_Option_Toggle of hDD iFile iField to DD_Retain
Set File_Field_Option_Toggle of hDD File_Field FileName.FieldName to DD_Retain

See: File_field_Option for more information.

Field_Option_Toggle

Type: Procedure set
Arguments: integer iField, integer iD_Option

See: File_Field_Option_Toggle for more information.