Listening for Changes

Visual LANSA Framework

Listening for Changes

Currently this part of the Virtual Clipboard feature is only available in Windows applications.

In the preceding section the use of the virtual clipboard for the exchange of information between command handlers was discussed.  In the example the user had to use the right mouse button and select a pop-up menu option to cause the information exchange to take place (i.e.: it was manually initiated).

However, in some situations the virtual clipboard facility is most effective when the exchange of information happens without user intervention.  When things are posted to the clipboard by the avSaveValue method you can use the special SignalChange(TRUE) parameter. The TRUE must be in uppercase.  For example, the tax calculator (DF_DET12) posts its latest calculation like this:

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

                             FromNValue(#DF_ELNET) Persistent(FALSE)

                             SignalChange(TRUE)

 

In other words all listening filters and command handlers will be notified that something on the clipboard has been changed. It is up to all listening filters and command handlers to decide whether they are interested in the thing that has been changed.

In DF_DET2 (New Employee) you will find a routine like this:

Evtroutine Handling(#AvFrameworkManager.avClipBoardChanged) WithId1(#ID1) ToNValue(#NValue) 

   If '#Id1.Value = Calculation'

      Change #Salary #NValue.value   

   Endif

Endroutine

 

Here DF_DET2 (New Employee) is listening to the system for clipboard changes. 

When one occurs, the Id1 value is immediately checked (both the calculators use a naming protocol that puts "Calculation" in the ID1 field).  If the clipboard value that has been changed is a calculation, then the new value is mapped into the salary field.

You can try this out by executing DF_DET2 (New Employee) and DF_DET12 (Tax Calculator) at the same time. As you do tax calculations they are immediately and automatically mapped into the new employee's salary field. 

Again, this very simple example demonstrates a foundation upon which more complex and elaborate information exchanges can take place.