Exchanging Information

Visual LANSA Framework

Exchanging Information

The shipped Tax Calculator (reusable part (DF_DET12) uses the virtual clipboard to exchange information between components.

If you look at the source of the tax calculator you will see this command being executed at the end of the tax calculation routine to save the calculation result onto the virtual clipboard:

Invoke #AvFrameworkManager.avSaveValue WithID1(Calculation) WithID2(Tax)

                             FromNValue(#DF_ELNET) Persistent(FALSE)

                             SignalChange(TRUE)

 

The normal calculator DF_DET13 also uses the clipboard:

After each calculation DF_DET13 executes this code to post calculation results:

Invoke #AvFrameworkManager.avSaveValue WithID1(Calculation) WithID2(Normal) 

                             FromNValue(#VTOTAL) Persistent(FALSE)

                             SignalChange(TRUE)

 

This is an example how to get net salary from the tax calculator: 

EVTROUTINE HANDLING(#MITM_TAXCALC.Click)

INVOKE method(#AvFrameworkManager.avRestoreValue) WITHID1(Calculation) WITHID2(Tax) TONVALUE(#Salary) USENVALUEDEFAULT(#Salary)

SIGNAL event(SomethingChanged)

ENDROUTINE

 

This is an example how to get salary from the standard calculator:

EVTROUTINE HANDLING(#MITM_NORMCALC.Click)

INVOKE method(#AvFrameworkManager.avRestoreValue) WITHID1(Calculation) WITHID2(Normal) TONVALUE(#Salary) USENVALUEDEFAULT(#Salary)

SIGNAL event(SomethingChanged)

ENDROUTINE

 

Note the use of the UseNDefault(#Salary) parameter, to ensure that the current value is unchanged if no calculation can be found on the clipboard.  What is being demonstrated by these examples is the exchange of information between the calculators and a form.

In summary both the tax and normal calculators post their latest calculation to the clipboard all the time.

This very simple concept is a foundation upon which more complex and elaborate information exchanges can be based.