Difference between revisions of "Arrays"

From Team Developer SqlWindows Wiki
Jump to: navigation, search
m (Added sample download link for "Passing arrays in messages" in section Arrays)
Line 37: Line 37:
 
       Call VisArrayCopy( SalNumberToWindowHandle( lParam ), uaCustomer, DT_Handle )
 
       Call VisArrayCopy( SalNumberToWindowHandle( lParam ), uaCustomer, DT_Handle )
 
</pre>
 
</pre>
 +
 +
 +
Here you can download a sample:
 +
*[http://samples.tdcommunity.net/index.php?dir=&file=WIKI_PassingArraysInMessages.zip WIKI_PassingArraysInMessages.zip]<br>
 +
<br>

Revision as of 22:19, 2 February 2009

This page covers Arrays from any datatype tips & tricks.

Contents


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: