contents   index   previous   next



SafeArrayAccessData

 

f90VB Modules

 

f90VBDefs, f90VBSafeArrays

Summary

 

Allows access to the elements of a Safe Array using a mapped Fortran array. After a call to SafeArrayAccessData, the safe array is locked until you issue a call to SafeArrayUnAccessData. Changes made on the elements of the mapped Fortran array automatically become reflected in the corresponding elements of the Safe Array.

Syntax

 

subroutine SafeArrayAccessData (SARef,FPtr,iRet)

{
integer(SAFEARRAY_KIND),intent(in):: SARef |
type(FSafeArray),intent(in):: SARef |
}
{
integer(POINTER_KIND),intent(out):: FPtr |
integer(BYTE_KIND),dimension(:),pointer:: FPtr |
integer(BYTE_KIND),dimension(:,:,:,:,:,:,:),pointer:: FPtr |
integer(SHORT_KIND),dimension(:),pointer:: FPtr |
integer(SHORT_KIND),dimension(:,:,:,:,:,:,:), pointer:: FPtr |
integer(LONG_KIND),dimension(:),pointer:: FPtr |
integer(LONG_KIND),dimension(:,:,:,:,:,:,:),pointer:: FPtr |
real(FLOAT_KIND),dimension(:),pointer:: FPtr |
real(FLOAT_KIND),dimension(:,:,:,:,:,:,:),pointer:: FPtr |
real(DOUBLE_KIND),dimension(:),pointer:: FPtr |
real(DOUBLE_KIND),dimension(:,:,:,:,:,:,:),pointer:: FPtr |
type(CURRENCY),dimension(:),pointer:: FPtr |
type(CURRENCY),dimension(:,:,:,:,:,:,:),pointer:: FPtr |
type(VARIANT),dimension(:),pointer:: FPtr |
type(VARIANT),dimension(:,:,:,:,:,:,:),pointer:: FPtr |
}
integer(HRESULT_KIND),intent(out),optional:: iRet

Arguments

 

SARef [Input]

A handle to, or a Fortran Safe Array structure containing a handle to, an allocated Safe Array descriptor.

 

FPtr [Input/Output]

A long integer variable, or a pointer-array with deferred shape of up to seven dimensions.

 

iRet [Output, Optional]

Upon return, iRet contains S_OK or an error code. See comments for more information.

Comments

 

Note that SARef must be a reference to an allocated Safe Array.

 

A call to SafeArrayAccessData puts a lock on the passed Safe Array, until SafeArrayUnAccessData is called.

 

If FPtr is a long integer variable, SafeArrayAccessData returns the address of the first element of the Safe Array. This is the same address as the beginning of the Safe Array’s data-block.

 

If FPtr is a Fortran array-pointer, SafeArrayAccessData maps the array-pointer to the same address space of the Safe Array’s data-block. The returned Fortran array-pointer has the same dimensions and indexes as the Safe Array it maps. This allows full access to the Safe Array elements using the mapped Fortran array. Because the Safe Array data and the Fortran array-pointer FPtr share the same memory address, any changes in the elements of the mapped Fortran array are automatically reflected in the elements of the Safe Array.

 

Note that the mapping becomes invalid once SafeArrayUnAccessData is called for the Safe Array or until FPtr is mapped to a different array.

 

Deallocating the Fortran array-pointer FPtr while mapped to a Safe Array is not recommended or necessary, because FPtr has not requested any memory from the operating system.

 

Note: Subroutine SafeArrayAccessData is not available for Absoft Pro Fortran in the current version of f90VB.

Argument iRet

 

Indicates success or failure of the subroutine. The following codes can be returned in this argument:

 

 

Value returned in argument iRet Description
S_OK Success.
E_UNEXPECTED The array could not be unlocked.
E_INVALIDARG The item pointed to by SARef is not a Safe Array descriptor

Examples

 

See example for SafeArrayCreate, SafeArrayLock, SafeArrayGetDim, Example 2.5 (User Manual - Chapter 2), Example 4.4 (User Manual - Chapter 4).

Related Topics

 

For information about See
Obtaining the value of a Safe Array element SafeArrayGetElement
Changing the value of a Safe Array element SafeArrayPutElement
Locking/Unlocking a Safe Array SafeArrayLock, SafeArrayUnlock
Obtaining the lock-counter of a Safe Array SafeArrayGetLocks
Allocating a Safe Array descriptor SafeArrayAllocDescriptor

 


SafeArrayAllocData