ModalResult

I will swear that the documentation does not contain any information about what happens when you assign a value to the ModalResult property of a form. In fact, ModalResult is a property of push buttons (PRIM_PHBN), but when a button is pushed, the ModalResult is supposed to be migrated to the form as well.

This became apparent when I had a form with a reusable that tried to catch invalid input when the user clicked on a button. Unfortunately, the reusable sent a signal to an event which then set the ModalResult property, closing the form no matter what I tried to do.

It turns out that assigning a value to ModalResult closes the modal form immediately.

Evtroutine Handling(ÆPHBN_1.Click)
  If Cond(...)
    ...
  Else
    #COM_OWNER.ModalResult := OK
  Endif
Endroutine

 

Interform communication

We performed the upgrade to Lansa 14 so now I am getting used to that. Some irritating bugs in the form UI have disappeared so so far I am happy 🙂

As I have said, I am very much learning the language at the moment and these are my notes. Today I wanted to one form to invoke a method in another form (provided it had been instantiated). Both forms would have been opened by a third form and I decided to let the third, the “parent”, form do the actual invocation.

The forms are, for reasons, named VLI510 (source), VLI710 (destination) and VLI500 (parent). In VLI710 (destination) I create the method that should be invoked:

Mthroutine Name(MTHSETUP)
...
Endroutine

In VLI510 (source) I create

Define_Com Class(#VLI500) Name(#VLI500) Reference(*DYNAMIC)
...
Mthroutine Name(Set_VLI500)
Define_Map For(*INPUT) Class(#VLI500) Name(#VLIPAR) Pass(*BY_REFERENCE)
Set_Ref Com(#VLI500) To(#VLIPAR)
Endroutine
...
If_Ref Com(#VLI500) Is_Not(*null)
#VLI500.VLI710UPD
Endif

And in VLI500 (parent) I have

Define_Com Class(#VLI510) Name(#VLI510) Reference(*DYNAMIC)
Define_Com Class(#VLI710) Name(#VLI710) Reference(*DYNAMIC)
...
If_Ref Com(#VLI710) Is(*null)
Set_Ref Com(#VLI710) To(*create_as #VLI710)
Endif
#VLI710.ShowForm
...
If_Ref Com(#VLI510) Is(*null)
Set_Ref Com(#VLI510) To(*create_as #VLI510)
Endif
#VLI510.ShowForm
#VLI510.Set_VLI500 VLIPAR(#COM_OWNER)
...
Mthroutine Name(VLI710UPD)
If_Ref Com(#VLI710) Is_Not(*null)
#VLI710.MTHSETUP
Endif
Endroutine

This actually works. So, I have a method on the destination form, VLI710.MTHSETUP. This is called from the parent forms method, VLI500.VLI710UPD, which is called from the source form. In order to have the reference to the parent form in the source form, the parent calls the VLI510.Set_VLI500 method with itself as the VLIPAR parameter.