Step 14 Understanding Events

Visual LANSA

Step 14. Understanding Events

FRM015 - Getting Started with Forms Programming

1.  Drag and drop field STD_DESCL on to the form. Set up its properties as follows:

Property

Value

LabelPosition

Top

Caption

Display the results

LabelHorAlignment

Left

LabelType

Caption

Width

374

 

2.  Change the properties of the first field STD_TEXT as follows

Property

Value

LabelPosition

Top

Caption

Enter some text

LabHorAlignment

Left

LabelType

Caption

 

     Your form should now look like the following:

3.  Select the first field STD_TEXT and create a Changed event for it. Remember you can do this either using the Events tab on the Details tab, or using the right mouse menu / Events : STD_TEXT.

4.  With the STD_TEXT selected, press F2. Alternatively use the right mouse menu and select Field : STD_TEXT / Features.

     The Features tab shows the events, properties and methods for the selected component, in this case field STD_TEXT.

5.  Click on the Views button in the tab toolbar and choose Category View:

6.  Expand the Intrinsics for this type of field. Scroll down and note that there is an UpperCase method.

7.  Double click on the UpperCase method to see the Feature Help for it.

 

8.  Add the following code to the STD_TEXT.Changed event routine. New code is shown in bold.

Evtroutine Handling(#STD_TEXT.Changed) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
#STD_DESCL := #STD_TEXT.upperCase
Endroutine
 

9.  Change the CHANGE statement in the CLEAR.Click event to include STD_TEXT.

Change Field(#STD_TEXT #STD_DESCL) To(*blanks)

 

10. Recompile and test your form. Type into the first field and observe the output in results field. Your form should look like the following:

     Observe that for every change event (character typed) the STD_TEXT.Changed event routine is executed and replaces STD_DESCL with the new value of STD_TEXT.

11. Change the STD_TEXT.Changed event routine logic to the following:

#STD_DESCL := #STD_TEXT.upperCase.Reverse
 

12. Recompile your form. Make sure the form was closed before recompiling.

13. Test your form. Type into the first field. The results should look like the following:

14. Clear the fields using the Clear button. Click on the Hello button. Your form should look like the following:

     The Changed event for field STD_TEXT has not been triggered. Programmatic changes to a component (in this case a field) do not trigger its events.