oi10:presentation_server:appendix_a_concatenating_properties

Appendix A - Concatenating Properties

In some circumstances it is possible to improve the performance of the Get/Set_Property interface by concatenating the arguments together using the system record-mark delimiter (@Rm), and passing them to the Presentation Server using a single function call rather than multiple calls.

For example, the following three statements:

                                                                                                                                        
 ItemPos  = Get_Property( @Window : ".LIST_ITEMS", "SELPOS", "" )
 ItemList = Get_Property( @Window : ".LIST_ITEMS", "LIST", "" )
 WinText  = Get_Property( @Window, "TEXT" )

Could be rewritten as:

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
   ObjxArray =        @Window : ".LIST_ITEMS"

   PropArray =        "SELPOS"

   IdxArray  =        ""

   

   ObjxArray := @Rm : @Window : ".LIST_ITEMS"

   PropArray := @Rm : "LIST"

   IdxArray  := @Rm : ""

   

   ObjxArray := @Rm : @Window

   PropArray := @Rm : "TEXT"

   IdxArray  := @Rm : ""

   

   DataArray        = Get_Property( ObjxArray, PropArray, IdxArray )

   

   ItemPos          = DataArray[1,@rm,1]

   ItemList         = DataArray[bCol2()+1,@rm,1]

   WinText          = DataArray[bCol2()+1,@rm,1]

Each of the arguments passed to Get_Property has been concatenated together with @Rm before passing to the function. The results are similarly returned @Rm-delimited, and they are parsed out using the "[]" operators and the bCol2() statement for maximum efficiency (Using bCol2() rather than col2() means the code is still performant in either an ANSI or a UTF8 environment).

Similarly individual calls to Set_Property like this:

                                                                                                                                             
 Call Set_Property( @Window : ".LIST_ITEMS", "SELPOS", 3 )
 Call Set_Property( @Window : ".LIST_ITEMS", "LIST", SomeListOfItems )
 Call Set_Property( @Window, "TEXT", "Select Item" )

Could also be rewritten as:

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
   ObjxArray =        @Window : ".LIST_ITEMS"

   PropArray =        "SELPOS"

   DataArray =        3

   IdxArray  =        ""

   

   ObjxArray := @Rm : @Window : ".LIST_ITEMS"

   PropArray := @Rm : "LIST"

   DataArray := @Rm : SomeListOfItems

   IdxArray  := @Rm : ""

   

   ObjxArray := @Rm : @Window

   PropArray := @Rm : "TEXT"

   DataArray := @Rm : "Select Item"

   IdxArray  := @Rm : ""

   

   Call Set_Property( ObjxArray, PropArray, DataArray, IdxArray )   

The advantage of this technique is that it avoids the overhead of the extra function calls into the Presentation Server, but obviously the downside is that it is it takes longer to type, construct, and maintain.

It is also worth bearing in mind that in the early days of OpenInsight 2 running on Window 3.1, the overhead involved in a call to the Presentation Server was much higher than with OpenInsight 10 running on a modern OS and hardware, and therefore the performance benefits were very noticeable. In current systems this may not be so, and may not yield better results if you are only dealing with one or two properties at a time. In this case it may be worth profiling your code to see if there is a significant improvement.

Caution must be observed when using synthetic properties with this concatenation technique, due to the way that the Get/Set_Property functions are implemented internally.

When you don’t use the @Rm concatenation method then Get_Property and Set_Property first try to process the request as a Synthetic property, and, if not found, it is then passed on to the Presentation Server. This obviously doesn’t cause any issues as no concatenation is involved.

When you do use the @Rm concatenation method both Get_Property and Set_Property first pass the arguments onto the Presentation Server, which deals with the properties it is responsible for. After that the arguments are scanned for any synthetic properties and processed accordingly.

In many cases this would have no effect unless the order in which the properties are called is critical.

Consider the following example:

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
   // Set the TEXT _without_ firing a CHANGED event

   // (This will NOT work!)

   

   ObjxArray =        "SYSTEM"

   PropArray =        "BLOCKEVENTS"

   DataArray =        TRUE$

 

   ObjxArray := @rm : @window : ".EDL_NAME"

   PropArray := @rm : "DEFPROP"

   DataArray := @rm : StrName

   

   ObjxArray := @rm : "SYSTEM"

   PropArray := @rm : "BLOCKEVENTS"

   DataArray := @rm : FALSE$

 

   Call Set_Property( ObjxArray, PropArray, DataArray )

In this case both BLOCKEVENTS property calls (non-synthetic properties) will be processed before the DEFPROP call (a synthetic property), meaning they will have no effect and the CHANGED event will fire.

  • oi10/presentation_server/appendix_a_concatenating_properties.txt
  • Last modified: 2023/10/25 10:49
  • by 127.0.0.1