4D v16.3Using object methods |
||
|
4D v16.3
Using object methods
Using object methods
You can attach a method to any active object in a form. Methods that are attached to individual objects on a form are called object methods. The following are some of the more common uses of object methods:
Here are some simple examples that perform operations on data. The following method calculates a total based on data in two other fields: Line_Total:=[Products]Price *[Orders]Quantity Here is a method to make all characters in a Name field uppercase: [Customers]Name:=Uppercase([Customers]Name) The following method concatenates values from a First Name field and a Last Name field and assigns the results to a variable named vName: vName:=[Employees]First Name+" "+[Employees]Last Name Because each object method is attached to its object, you create object methods from within the Form editor. For information on how to use methods, see Editing methods. Object methods run when certain events occur. For example, the action associated with a tab control makes sense only when a user clicks a tab. In a scrollable area, you may want the method to execute only when the user double-clicks an item. You select an event by clicking on the associated check box. To select or deselect all the events at once, press the Ctrl key (Windows) or the Command key (Mac OS) while clicking any event. If you need to execute different code segments for several different events, use a Case of...Else...End case statement in your method and test for each event you checked in the Events section. To test for an event, you use the Form event function and the Form Events constants. An example shell for an object method might look like this: Case of To create an object method:
To open an object method:
You can delete an object method at any time. To do so, select the object to which the method is attached and then choose Clear Object Method from the Object menu.
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
4D Design Reference ( 4D v16) |