contents   index   previous   next



Accessing the data in a Safe Array

 

Before your application accesses the data of a Safe Array, you must lock the array. Remember that Safe Arrays are managed by the operating system, which means the OS could, if necessary, move the data-block of a Safe Array to a different memory location. Locking the array ensures that the pointer to the data-block stored in the Safe Array descriptor is valid and current. In addition, while a Safe Array is locked the OS will not change the memory location of the array’s data-block, and any other users or applications using the same Safe Array will not be able to re-dimension or destroy the array. Locking a Safe Array, however, does not stop other users or applications from changing the values in the array’s data-block. When your application has finished working with a Safe Array’s data, it should unlock the array, so the OS can take over control of the data-block again.

 

To lock and unlock a Safe Array you use f90VB’s procedures SafeArrayLock and SafeArrayUnlock.

 

f90VB’s Safe Arrays Library provides two basic mechanisms to access the data in a Safe Array; using a combination of calls to SafeArrayGetElement and SafeArrayPutElement procedures, or by mapping the Safe Array data-block into a Fortran array through the use of SafeArrayAccessData. The following sections explain how to implement each mechanism and shortly discuss their particular benefits and disadvantages.