Request_Find

Send Request_Find of oCustomer_DD GT Customer.File_Number 1

The Request_Find message is similar to the Find message with the exception that the table to find in is passed as a parameter. This allows a parent table find message to be sent to a child. The DDO will direct the find to the proper DDO for you. Normally, you can just use the Find message and send the message directly to the proper DDO.

The syntax for Request_Find is:

Send Request_Find {of hoDD} mode File Index

The Find message actually sends the Request_Find message. The following two lines of code will do the same thing:

// Find using the Find message

Send Find of oCustomer_DD GT 1

 

// Find using the Request_Find message

Send Request_Find of oCustomer_DD GT Customer.File_Number 1

Assuming that oCustomer_DD is a parent DDO of oOrderHea_DD, the two lines of code will do the same thing:

// Find using the Find message sent directly to the DDO

Send Find of oCustomer_DD GT 1

 

// Find using the Request_Find message sent indirectly to the parent DDO

Send Request_Find of oOrderHea_DD GT Customer.File_Number 1

Sending a Request_Find message indirectly has some interesting implications for advanced usage. By augmenting the find procedures in DDOs, you can make two different DDOs respond differently to finding the same record. For example, we could augment the Request_Find message for DDO oOrderHea_DD as follows:

Procedure Request_Find Integer iMode Integer iFile Integer iIndex

    If (iFile <> Customer.File_Number) begin

        Forward Send Request_Find iMode iFile iIndex

    end

End_Procedure

In this example, we have disabled any finding of the Customer table records by DDO oOrderHea_DD. Request_Find messages for the Customer table that are sent to oOrderHea_DD are ignored. All other finds are processed, and a find sent directly to Customer_DD would also be processed.

Finds and  DEOs

The above samples with Find and Request_Find shows how to perform finds in batch processes. Find support is built directly into DEOs. These finds are initiated when a user presses a key (F7, F8, F9), clicks on a button or selects a menu option. This sends one of the DEO find messages (Find_First, Find_Next, Find_GE, Find_LE, Find_Previous and Find_Last). These messages all send Request_Find to the DEO passing the appropriate find-mode. The DEO Request_Find sends the private Item_Find message to the DDO passing find-mode and the DEO’s file-number and field- number. The DDO Item_Find message performs the find as follows:

 

Below is an example of a simplified DEO Request_Save procedure and an even more simplified DDO Item_Find procedure.

// The DEO Find Process

Procedure Request_Find integer eFindMode

    Integer iFile iField

    Handle  hoDDO

    Get Data_File  to iFile  // table's file number bound to DEO

    Get Data_Field to iField // field number bound to DEO

    Get Server     to hoDDO  // DDO serving the DEO

    If (iFile>0) begin

        send Item_Find of hoDDO eFindMode iFile iField

    End

End_procedure

:

:

// the DDO Item_Find process

Procedure Item_Find integer eFindMode integer iFile integer iField

    integer iIndex

 

    Get File_Field_Index iFile iField to iIndex // get index of file.field

    If (iIndex=-1) Procedure_Return // only find if we have an index

 

    Send Request_Entry_Update iFile 1 // Move DEO data into file-buffers

    Send Request_Find eFindMode iFile iIndex // perform the find

End_Procedure

The above code is quite simplified. The actual procedures pass additional parameters and perform additional tasks, which have been removed for the sake of simplicity. This is provided to give you a idea of what the DEO -> DDO find process looks like.

See Also

Find and Clear Operations in DDOs