4D v14.3

Find and replace in methods

Home

 
4D v14.3
Find and replace in methods

Find and replace in methods  


 

 

The Method editor has specific find and replace functions that apply to the current window. 

The find area located in the toolbar of each method window can be used to carry out simple searches or to call the Find dialog box (see Method editor).

The Find/Replace commands for methods are located in the Find submenu of the Edit menu of 4D:

Note: The find commands located above the Find submenu are not specific to the Method editor but may be used to search for a value among all the methods. For more information, refer to Searching and replacing in the Design.

Find  

Selecting the Find... command displays the following dialog box:

The search defined in this dialog box will be performed in the method located in the foreground.

  • The “Find What:” area enables you to enter the string of characters to be searched for. This area is a combo box that stores the last 15 character strings that have been searched for or replaced during the session. If you highlight text before choosing the Find... command, it will appear in this area. You can then either use this text or replace it with another.
  • The Whole Word option is used to limit the search to exact occurrences of the word being searched for. When this option is checked, for instance, a search for “client” will not find either “clients” or “myclient.” By default, this option is not checked; therefore, a search for “var” will find “Myvar,” “variation,” etc.
    Be careful, unlike the Whole Object Name option of the Find in Design dialog box, the Whole Word option does not take object names into account. For example, with this option, searching for the string “My” in a method will find the “My Variable” variable. This is not the case for an overall search using the Whole Object Name option, where the same result will not be found in the context of the above example since the whole object name (of the variable found previously) is “My Variable” and therefore does not correspond exactly to the string entered (“My”).
  • The Case Sensitive option is used to take the case of characters as they were entered in the “Find What:” area into account. For instance, a search for “MyVar” will not find “myVar.”
  • The Previous/Next radio buttons are used to set the direction of the search: towards the beginning or end of the current method, starting from the initial location of the cursor.

When you click on OK, 4D begins searching from the current text insertion point and continues to the end of the method. The first item corresponding to the set criteria is thus selected in the Method editor window. It is then possible to continue the search using the Find Next and Find Previous commands of the Edit menu.

The Find Same command is used to find character strings identical to the one selected. This command is only active if you have selected at least one character in the Method editor. 

The search carried out is of the “Find Next” type in the current method.

The Bookmark All command is enabled when a search has already been specified in the find or replace dialog box. When you select this command, 4D puts a bookmark at each line that contains an item corresponding to the "current" search criteria. This makes it easy to spot all the search results. 

For more information about bookmarks, refer to the "Using bookmarks" section in Writing a method.

Replace  

The Replace command displays the following dialog box:

  • The “Find What:” area is used to define the character string or the expression to be searched for. As in the Find dialog box, this area is a combo-box that stores the last 15 character strings searched for. If you highlight text before choosing the Replace command, it will appear in this area.
  • The “Replace with:” area is used to define the character string that will replace the one defined above. This area is also a combo-box storing the last 15 character strings that have been searched for or replaced.
  • The Whole Word option is used to find/replace only character strings that correspond exactly to the string entered. In this case, for instance, a search for “client” will not find the strings “clients” or “myclient,” etc.   
  • The Case Sensitive option is used to find/replace only character strings having the same case as that of the entered string. For instance, a search for “MyVar” will not find “myVar.”
  • As in the Find dialog box, the Previous and Next buttons are used to set the direction of the search: towards the beginning or end of the current method, starting from the initial location of the cursor.

The Replace button is used to launch the search and replace the first occurrence found. 4D begins searching from the current text insertion point and continues to the end of the method. It is then possible to continue finding/replacing using the Replace Next and Replace Previous commands of the Edit menu.

The Everywhere button is used to replace all the occurrences corresponding to the search criteria directly in the open method.

The Goto Definition command opens the definition of an object referenced in the Method editor (method, field, table or form) directly in a new window. To do this, place the cursor inside the object name (or select it) and choose Goto Definition... from the Method menu or from the context menu of the editor.

This command functions with the following objects:

  • project method: displays the contents of the method in a new window of the Method editor.
    Note: This function is available through the keyboard shortcut Ctrl+K (Windows) or Command+K (Mac OS) with the project method name selected.
  • field: displays the properties of the field in the inspector of the structure window,
  • table: displays the properties of the table in the inspector of the structure window,
  • form:displays the form in the Form editor ,
  • variable (local, process, interprocess or $n parameter): displays the line declaring the variable in the current method or among the compiler methods.

The Search references... command found in the Method menu or the context menu of the Method editor finds all the objects (methods and forms) in the database where the current item of the method is referenced (used).

The current item is either the one selected or the one where the cursor is located. It can be a field name, variable name, command, string, and so on. For example, the following action looks for all the occurrences of the vlNbCmd variable in the database:

This command displays its results in a new window. For more information about the results window, refer to Results window.

The Search Callers command in the Method menu is only enabled for project methods. It searches for all the objects (other methods or menus) that reference the project method.

Note: The Search Callers... command is also available on the Methods Page of the Explorer. 

This command displays its results in a new window. For more information about the results window, refer to Results window.

This specific search command is located in the Method menu. It opens a dialog box where you can indicate the line number you want to find. When you click OK, the editor finds and highlights that line in the method. This type of search is useful when used in conjunction with the compiler, which flags runtime errors by the line number in which they occur.

You can choose whether or not to display lines numbers in the Method editor window. This option is described in the Method editor.

 
PROPERTIES 

Product: 4D
Theme: Editing methods

 
ARTICLE USAGE

4D Design Reference ( 4D v14 R2)
4D Design Reference ( 4D v13.4)
4D Design Reference ( 4D v14 R3)
4D Design Reference ( 4D v14.3)
4D Design Reference ( 4D v14 R4)

Inherited from : Find and replace in methods ( 4D v12.4)