Redefine the Ancestor s Methods

Visual LANSA

Redefine the Ancestor's Methods

The ancestor form #EOEXAM01 contains a method routine which displays a message box when the Open option is selected in the File menu:

Mthroutine HandleFileOpen
Use Message_Box_Show (ok Ok Info #Com_Owner.Name 'Ancestor HandleFileOpen method invoked') (#Std_Obj)
Endroutine

 

In the inheriting form exactly the same message is displayed when the Open option of the File menu is selected:

Sometimes you may want to modify the ancestor's methods in the inheriting form. You do this by using a method routine with *REDEFINE option.

To see how this works add a method routine to the inheriting form #EOEXAM02 which overrides the HandleFileOpen method of the ancestor form by changing the message text  to "Descendant HandleFileOpen method invoked":

MTHROUTINE NAME(HandleFileOpen) OPTIONS(*REDEFINE)
Use Message_Box_Show (ok Ok Info #Com_Self.Name 'Descendant HandleFileOpen method invoked') (#Std_Obj)
Endroutine

 

Compile the form and execute it. Select the Open option from the File menu. The redefined message text is displayed:

Ý 6.21.1 Form Ancestor