From Team Developer SqlWindows Wiki
Revision as of 22:19, 2 February 2009 by DaveRabelink (Talk | contribs)

Jump to: navigation, search

This page covers Arrays from any datatype tips & tricks.


Pointer2.png Passing arrays in messages (any datatypes) Pointer.png

(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 )

Here you can download a sample: