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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s