From Team Developer SqlWindows Wiki
Revision as of 12:56, 12 September 2008 by (Talk)

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

This page covers arrays from any datatype tips & tricks.


Pointer.pngPassing arrays in messages (any datatypes)

(From CenturaPro september 1999)
To pass arrays using messages, use this nice trick to convert the address of any type of array
to a number and send them along as wParam or lParam.

At the source (sending side) do this to pass arrays to a window

   ! Construct an array with weekdays
   Set saWeekDay[0] = "Monday"
   Set saWeekDay[1] = "Tuesday"
   Set saWeekDay[2] = "Wednesday"
   ! Construct an array with customer objects
   Set uaCustomer[0].sivCustomerName = "Brendan Perry"
   Set uaCustomer[0].nivCustomerID = 1
   Set uaCustomer[1].sivCustomerName = "Lisa Gerrard"
   Set uaCustomer[1].nivCustomerID = 2
   ! Get the address of the arrays as number
   Set nAddressStringArray = SalWindowHandleToNumber( saWeekDay )
   Set nAddressUDVArray = SalWindowHandleToNumber( uaCustomer )
   ! Send along the addresses as wParam and lParam
   Call SalPostMsg( frmMain, SAM_User, nAddressStringArray, nAddressUDVArray )

Now at the receiving side (frmMain), convert the array address back to an array variable

   On SAM_User
      Call VisArrayCopy( SalNumberToWindowHandle( wParam ), saWeekDay, DT_String )
      Call VisArrayCopy( SalNumberToWindowHandle( lParam ), uaCustomer, DT_Handle )