Progress
ADM 2 Reference


The Need For Two Different Syntaxes

Properties store the current state of the object, so reading and writing them is a high-frequency activity. It pays to optimize high-frequency activities, even when the net gain per operation is small. The pseudo-functions provide that slight optimization, and should be used in code that runs inside a SmartObject. Code that runs outside the Smart world—basic 4GL and Open4GL routines—should use the conventional get/set functions.

Figure 2 shows the {get} code reformatted and commented. The {set} code is very similar.

/* {get propname returnvar [ownerhandle]} */ 
&IF "{3}":U = "":U &THEN               /* if no handle is passed in... */  
   &IF DEFINED(xp{1}) NE 0 &THEN          /* but there is an xp macro defined */ 
      ASSIGN  
         ghProp = WIDGET-HANDLE(             /* pick up the handle to the */ 
          ENTRY(1,                        /* target proc’s ADM-DATA table */
          TARGET-PROCEDURE:ADM-DATA,   
           CHR(1)))                    
         ghProp = ghProp:BUFFER-FIELD('{1}':U)  /* then pick up the handle */ 
                                             /* to the slot for the prop */ 
         {2} = ghProp:BUFFER-VALUE           /* and finally assign the */ 
                                             /* value in the slot to */  
                                             /* the prop var passed in */ 
&ELSE                                  /* and there is no xp macro defined */ 
      {2} = dynamic-function( 
            "get{1}":U IN TARGET-PROCEDURE)  /* set the prop var by */ 
                                             /* building and firing a call */ 
                                             /* to the ordinary function */ 
   &ENDIF                                 /* end xp-macro-defined */ 
&ELSE                                  /* a handle was passed in... */ 
   &IF DEFINED(xp{1}) NE 0 &THEN          /* and if there is an xp macro */ 
      ASSIGN  
        ghProp = WIDGET-HANDLE(           /* pick up the handle to */
                ENTRY(1,                  /* the passed-in handle’s */ 
                {3}:ADM-DATA,             /* props table */
                 CHR(1)))  
        ghProp = ghProp:BUFFER-FIELD('{1}':U)  /* pick up the handle to */
                                          /* the slot for the prop in */
                                             /* that table */ 
        {2} = ghProp:BUFFER-VALUE         /* and finally set the variable */
                                             /* with contents of that slot */   
   &ELSE                                  /* but no xp macro defined */ 
      {2} = dynamic-function(             /* set the var by building */
             "get{1}":U IN {3})           /* and firing a call to the */
                                             /* ordinary function */  
   &ENDIF                                /* end if-xp-macro-defined */ 
&ENDIF                                /* end if-no-handle-passed-in */ 

Figure 2: Commented Source Code Of GET Pseudo-function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095