- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to create a two dimension safearray. But the third parameter of the function SafeArrayCreate(vt, cDims, ab) defined in the oleaut32.f90 is a variable of TYPE(SA_BOUNDS). here is the define:
[fortran]
INTEGER(INT_PTR_KIND()) FUNCTION SafeArrayCreate(vt, cDims, ab)
!DEC$IF DEFINED(_X86_)
!DEC$ ATTRIBUTES DEFAULT, STDCALL, ALIAS : '_SafeArrayCreate@12' :: SafeArrayCreate
!DEC$ELSE
!DEC$ ATTRIBUTES DEFAULT, STDCALL, ALIAS : 'SafeArrayCreate' :: SafeArrayCreate
!DEC$ENDIF
use ifwinty
INTEGER*4, INTENT(IN) :: vt
!DEC$ ATTRIBUTES VALUE :: vt
INTEGER*4, INTENT(IN) :: cDims
!DEC$ ATTRIBUTES VALUE :: cDims
TYPE(SA_BOUNDS), INTENT(IN) :: ab
!DEC$ ATTRIBUTES REFERENCE :: ab
END FUNCTION SafeArrayCreate
[/fortran]
and here is the define of the SA_BOUNDS int the ifwinty.f90
[fortran]
TYPE SA_BOUNDS
SEQUENCE
INTEGER*4 extent
INTEGER*4 lbound
END TYPE SA_BOUNDS
[/fortran]
in the SafeArrayCreate, ab is a variable of TYPE(SA_BOUNDS), not a pointer. however, in the msdn, the third parameter of SafeArrayCreate is a pointer, so i can define a array of SAFEARRRAYBOUND , and pass the address to the third parameter to define a multidimension safearray.
[cpp]
SAFEARRAY * SafeArrayCreate( VARTYPE vt, unsigned int cDims,
SAFEARRRAYBOUND FAR* rgsabound );
[/cpp]
Can anybody help me how to define a multidimension safearray?
thankyou!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Declare the interface with
[fortran]
...
TYPE(SA_BOUNDS), INTENT(IN) :: ab(dDims)
!DEC$ ATTRIBUTES REFERENCE :: ab
...
[/fortran]
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So, you mean the interface in the oleaut32.f90 is wrong? Another question, Do you have some reference for me to write fortran COM program?
the book is scarce, Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had a type-o, i had dDims, not cDims
If that interface were used to call a Fortran subroutine (your are not)
.AND.
if cDims were .gt. 1
The yes, it would have been in error.
You are calling a C routine Both declarations would work
The original interface would work for that (assuming SEQUENCE use and your array elements are adjacent in memory)
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page