Modifying user-defined functions

You can change the definition of a user-defined function at any time. You change the processing performed by the function by modifying the statements in the Script view. You can also change the return type, argument list, or access level for a function.

StepsTo change a function’s return type, arguments, or access level:

  1. Do one of the following:

    • In the Function painter, open the global function.

    • Open the object that contains the object-level function you want to edit and select the function from the Function list.

  2. Make the changes you want in the Prototype window.

    If the Prototype window is hidden, click the toggle button to display it.

  3. Select File>Save from the menu bar.

StepsTo change a function’s name:

  1. If desired, modify the function’s return type, arguments, or access level as described in the previous procedure.

  2. Do one of the following:

    • In the Function painter, select File>Save As from the menu bar and enter a name.

    • In the Script view, enter a new name in the Function Name box.

    When you tab off the box, the new function name displays in the Function List view.

Changing the arguments

You can change a function’s arguments at any time using the pop-up menu in the Prototype window:

NoteTo change the position of an argument To change the position of an argument, delete the argument and insert it as a new argument in the correct position.

Recompiling other scripts

Changing arguments and the return type of a function affect scripts and other functions that call the function. You should recompile any script in which the function is used. This guarantees that the scripts and functions work correctly during execution.

Seeing where a function is used

PowerBuilder provides browsing facilities to help you find where you have referenced your functions. In the System Tree or Library painter, select a target, library, or object and select Search from the pop-up menu. You can also search multiple entries in the Library painter:

StepsTo determine which functions and scripts call a user-defined function:

  1. Open the Library painter.

  2. In a List view, select all the entries you want to search for references to the user-defined function.

  3. Select Entry>Search from the menu bar.

    The Search Library Entries dialog box displays.

  4. Specify the user-defined function as the search text and specify the types of components you want to search.

  5. Click OK.

    PowerBuilder displays all specified components that reference the function in the Output window. You can double-click a listed component to open the appropriate painter.

For more about browsing library entities, see “Searching targets, libraries, and objects”.