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.
#COM_OWNER.ModalResult := OK
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:
In VLI510 (source) I create
Define_Com Class(#VLI500) Name(#VLI500) Reference(*DYNAMIC)
Define_Map For(*INPUT) Class(#VLI500) Name(#VLIPAR) Pass(*BY_REFERENCE)
Set_Ref Com(#VLI500) To(#VLIPAR)
If_Ref Com(#VLI500) Is_Not(*null)
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)
If_Ref Com(#VLI510) Is(*null)
Set_Ref Com(#VLI510) To(*create_as #VLI510)
If_Ref Com(#VLI710) Is_Not(*null)
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.