|
When you open the Function Painter from the Power Panel and declare a function, you are declaring a global function that can be called directly from any script in the application.
When you declare a function using the function item in the Declare Menu in the Window Painter, User Object Painter, Menu Painter, or PowerScript Painter, you are declaring a shared function; the name of the menu item specifies its scope.
|
Painter
|
Scope
|
|
Window Painter
|
Window level
|
|
User Object Painter
|
User-Object level
|
|
Menu Painter
|
Menu level
|
When you declare a function in the PowerScript Painter, the scope is determined by the painter from which you open the PowerScript Painter and the menu item name identifies the scope of the function.
To call a shared function from another object in the application, use the dot notation:
objectname.functionname(argument,...,argument)
To declare a function:
- Select the function menu item from the Declare Menu in the painter. The Select Function window displays the current function and the functions declared for the current object.
- Click New. The Function Declaration window displays.
- Enter the Name of the function, the data type of the return value, if any, and any arguments for the function.
- Click OK. The Function Painter workspace displays.
- Enter the statements for the function.
- Click the Return icon, press Ctrl+F4, or select Close from the File Menu. PowerBuilder compiles the function, closes the Function Painter workspace and displays the painter from which you opened the Function Select window.
|