Objects

From Team Developer SqlWindows Wiki
Revision as of 22:05, 11 September 2008 by DaveRabelink (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page covers UDV / objects tips & tricks.

Contents


Pointer.pngHow to copy one object (instance) to another

Create a CopyFrom function in the class of the object (instance) which copies all attributes from the source object to the destination object.

Functional Class: fcCustomer
   Instance Variables
      String: sivName
      Number: nivCustomerId
   Functions
      Function: CopyFrom
         Parameters
            fcCustomer: puSourceObject
      Actions
            Set sivName = puSourceObject.sivName
            Set nivCustomerId = puSourceObject.nivCustomerId

Having such a function in the class results in the next usage for instances.
Below you can see how to copy the contents (data) from the Customer1 object to Customer2.
After the Call, the two objects have the same data values.

Local variables
   fcCustomer: uCustomer1
   fcCustomer: uCustomer2
Actions
   Call uCustomer2.CopyFrom( uCustomer1 )

To copy objects which contains nested objects, you can reuse the CopyFrom functions
of the nested UDV's like this

Functional Class: fcAdress
   Instance Variables
      String: sivStreet
      String: sivCity
   Functions
      Function: CopyFrom
         Returns
         Parameters
            fcAdress: puSourceObject
         Actions
            Set sivStreet= puSourceObject.sivStreet
            Set sivCity= puSourceObject.sivCity

Functional Class: fcCustomer
   Instance Variables
      String: sivName
      Number: nivCustomerId
      fcAdress: uivAdress
   Functions
      Function: CopyFrom
         Returns
         Parameters
            fcCustomer: puSourceObject
         Actions
            Set sivName = puSourceObject.sivName
            Set nivCustomerId = puSourceObject.nivCustomerId
            Call uivAdress.CopyFrom( puSourceObject.uivAdress )

Pointer.pngHow to clear data of an object

1) Create a Clear function in the class of the object (instance) which sets all instance variables to initial values.

Functional Class: fcCustomer
   Instance Variables
      String: sivName
      Number: nivCustomerId
   Functions
      Function: Clear
         Returns
         Parameters
         Actions
            Set sivName = STRING_Null
            Set nivCustomerId = NUMBER_Null

! Below the code to clear an object
Call uCustomer1.Clear( )

2) For TD versions offering the new statement

! Below the code to clear (initialise) an object
Set uCustomer1 = new fcCustomer