KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How access an array from a different method or process
PRODUCT: 4D | VERSION: 6.8.5 | PLATFORM: Mac & Win
Published On: February 26, 2004

Version 6.8 and 2003

4D does not allow you to pass an array as a parameter to a method. However, there are number of ways to gain access to an array that is created from a different method or process.

1) You can pass a pointer to an array as a parameter. This method will work only with a process or interprocess array.

Example:

` Method1
Method2 (->MyArray)

` Method2
C_POINTER($1)

This method is the most common use because all changes that you made to the array within the called method affect the array directly.

2) You can put an array into a blob variable and pass the blob variable as a parameter. This approach can be used when dealing with multiple processes. Let's suppose you need to create a new process to execute a method and the method needs to use the array that is created from the calling process. If the array is an interprocess array, then there will be no problem for any process to access it. However, if the array variable is a local or process array, passing the pointer to the array as a parameter method will not work.

Example

` Method1:
VARIABLE TO BLOB (MyArray;vBlob)
$procid:=New process ("Method2";32000;"ProcessName";vBlob)

` Method2
C_BLOB($1)
ARRAY LONGINT(MyArray;0)
BLOB TO VARIABLE ($1; MyArray)