VisualAge(R) Help

Attribute-to-script connection example

In this example, the contents of two text entry fields, First name and Last name, are concatenated and placed in a third text entry field, Full name.
achxmp

Steps for creating this example

  1. Build the user interface shown here.

    Use the Change name choice on the pop-up menus of the entry fields to change their names to First Name, Last Name, and Full Name.

  2. Open the Script Editor window by selecting behaved icon in the lower-right corner of the Composition Editor.
  3. Use the Script Editor to create and save the following method:
    concatenateNames
    | firstName lastName |
    firstName :=
      self subpartAttributeValue: #(#'First Name' #string).
    lastName :=
      self subpartAttributeValue: #(#'Last Name' #string).
    ^firstName, ' ', lastName.
    
  4. Open the Composition Editor by selecting compeds icon in the lower-right corner of the Script Editor.
  5. Select Connect from the pop-up menu of the Full Name text entry field.
  6. Click on the free-form surface; then select More.
  7. In the Connections window, do the following:
    1. Specify the string attribute of the Full Name field and the concatenateName method.
    2. Select Make.

The connection appears as a double-headed arrow pointing to an icon representing the script.

The string attribute of the Full Name text entry takes value based upon the script that combines the values of the other two entry fields. Whenever either of the source string attributes changes in value, the script runs again, updating the contents of the Full Name field.


[ Top of Page | Previous Page | Next Page | Table of Contents ]