Was this helpful?
How You Can Call a Find Dialog Frame
The Find or Replace dialog frame is useful in frames that have entry fields containing long textual data that may require editing. The callframe statement may optionally pass a reference for an entry field to be searched; but if it is omitted, the Find dialog frame automatically looks for an active entry field on the form of the parent frame.
You can indicate the style of dialog that you want to have displayed, “Find” or “Replace,” by passing a flag in the callframe statement. This overrides the initial dialog style that the frame was created with. If you omit this flag, the default dialog style is used.
In the following example, a callframe statement specifies both the dialog style and a particular entry field, “textfield”, as the field to search at runtime. This frame is then invoked with Find and Replace menu items. To do this:
1. On a pull-down menu called “Edit” on the frame from which you will be calling the Find dialog, create a menu button called “Find” and a menu button called “Replace”.
2. Create an entry field called “textfield.”
3. Add the event block for the Find menu item:
on click menu.edit.find =
{
     callframe My_Find_Dialog(searchfield =
               field(textfield),
               allowreplace = FALSE)     /* Find */
               with parentframe = CurFrame;
}
4. Add the event block for the Replace menu item:
on click menu.edit.replace =
{
     callframe My_Find_Dialog(searchfield =
               field(textfield),
               allowreplace = TRUE)     /* Replace */
               with parentframe = CurFrame;
}
In the preceding example, the Find and Replace menu items could have been used to search any entry fields on the form by omitting the searchfield parameter.
If there is only one entry field on a form that can be searched, the Find or Replace dialog can be opened using an openframe statement instead of callframe. This lets you switch back and forth between the parent frame and the dialog without having to close the dialog each time. In this case, you should verify that the dialog is not already open before creating a new instance of it. To facilitate this, the dialog sends a FindDlgClose or ReplaceDlgClose user event to its parent window whenever it is closing.
In the following example, a flag is set whenever the Find dialog is opened, and cleared whenever the corresponding user event is received. It is based on the previous example except that now an openframe statement is used, and the dialog for one active entry field is opened:
initialize()=
declare
          dlg_open_flag = integer not null;
enddeclare
{
          dlg_open_flag=FALSE;
}

on UserEvent 'FindDlgClose'
on UserEvent 'ReplaceDlgClose'=
{
          dlg_open_flag = FALSE;
}
on click menu.edit.find =
{
          if dlg_open_flag = FALSE then
                    dlg_open_flag = TRUE;
                    openframe My_Find_Dialog()
                    with parentframe = CurFrame;
          endif;
}
Last modified date: 12/20/2023