- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to create a COM server passing dynamically sized arrays back and forth - i.e. the server doesn't know how big the arrays will be before they arrive and return arrays are dynamically within the server.
I don't see how this can be done using the COM Server wizard which requires that the bounds of arrays are specified.
Does anyone have any idea how to do this or even better any example code. The examples in the documentation do not cover the case of array properties at all.
Thanks
Roger
I don't see how this can be done using the COM Server wizard which requires that the bounds of arrays are specified.
Does anyone have any idea how to do this or even better any example code. The examples in the documentation do not cover the case of array properties at all.
Thanks
Roger
Link Copied
13 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm puzzled by the wording of your question. At _some_ point, the array size _is_ know at which time you can pass it here and there with ease.
If your arrays (or data structures for that matter) are large using COM involves significant overhead. Stuff all into a a byte array and then use the CopyMemory API to pass a pointer to the byte array on to the recipient.
HTH,
Gerry T.
If your arrays (or data structures for that matter) are large using COM involves significant overhead. Stuff all into a a byte array and then use the CopyMemory API to pass a pointer to the byte array on to the recipient.
HTH,
Gerry T.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks very much, I'll get a copy and try it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm sure you're right and that it is possible. I think its more a limitation in the COM Sever Wizard for Visual Fortran than a fundamentally impossible task.
The COM server wizard seems to require that the rank and bounds of array properties are specified at compile time. I can compile a com server where I dynamically allocate the property that I am trying to pass but get a RankMismatch exception when the .NET runtime I'm using to communicate with the server attempts to read the property.
The COM server wizard seems to require that the rank and bounds of array properties are specified at compile time. I can compile a com server where I dynamically allocate the property that I am trying to pass but get a RankMismatch exception when the .NET runtime I'm using to communicate with the server attempts to read the property.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The COM wizard rightly assumes that you're going to use SafeArrays. The RankMismatch error is probably because you're passing rectangular arrays to .NET whose rows are Fortran columns. Pass the transpose and cross your fingers.
HTH,
Gerry T.
HTH,
Gerry T.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But as far as I can tell fortran doesn't support safe arrays so I'm attempting to pass fundamentally different types across the interface? Even the one-dimensional case only works if the array I pass is of fixed size at compile time - any attempt to dynamically allocate an array and pass it (both as an allocatable array or a pointer) and I just get zeros passed across the interface.
Roger
Roger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just because SafeArrays are not part of Fortran doesn't mean you can't use them. CVF has a number of modules with interfaces to the appropriate APIs.
Look in SAMPLES/MIXLANG/ARRAY.
Also, look at its modification NewArrays.zip at ftp://users.jagunet.com/pub/users/jtermine/VBstrings/
HTH,
Gerry T.
Look in SAMPLES/MIXLANG/ARRAY.
Also, look at its modification NewArrays.zip at ftp://users.jagunet.com/pub/users/jtermine/VBstrings/
HTH,
Gerry T.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Gerry
> Just because SafeArrays are not part of Fortran
> doesn't mean you can't use them. CVF has a number of
> modules with interfaces to the appropriate APIs.
>
> Look in SAMPLES/MIXLANG/ARRAY.
Where would I find this, as part of the installation? Don't seem to have it.
> Also, look at its modification NewArrays.zip at
> ftp://users.jagunet.com/pub/users/jtermine/VBstrings/
Couldn't get here as anonymous user. Anywhere else I might find it?
>
> HTH,
> Gerry T.
Thanks
Roger
> Just because SafeArrays are not part of Fortran
> doesn't mean you can't use them. CVF has a number of
> modules with interfaces to the appropriate APIs.
>
> Look in SAMPLES/MIXLANG/ARRAY.
Where would I find this, as part of the installation? Don't seem to have it.
> Also, look at its modification NewArrays.zip at
> ftp://users.jagunet.com/pub/users/jtermine/VBstrings/
Couldn't get here as anonymous user. Anywhere else I might find it?
>
> HTH,
> Gerry T.
Thanks
Roger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The samples are installed under Program FilesMicrosoft Visual StudioDF98SAMPLES. You may or may not have the samples installed to your hard disk, depending on what version of CVF you first installed and whether you selected a standard or custom install. The samples are on the CD-ROM under INFODFSAMPLES.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Roger,
I've attached the NewArrays.zip, courtesy of John Termine.
Ciao,
Gerry T.
ps
Where is John, anybody?
I've attached the NewArrays.zip, courtesy of John Termine.
Ciao,
Gerry T.
ps
Where is John, anybody?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks very much.
Seem to have lost or not installed my samples. Will be playing hunt the CD for the rest of the day.
Roger
Seem to have lost or not installed my samples. Will be playing hunt the CD for the rest of the day.
Roger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re John: Hope I'm not too discourteous by publishing a private e-mail from last September:
Hi Jugoslav,
How are you doing? And how are all my VF friends? Hope everyone is well. I am alive! Well? Well that's a tougher question! Nah, everything's fine. Just doing different stuff. Over the last year I became responsible for the I/T departments for my division in the US. Haven't written any code in a long while. Bummer. Actually, I wrote a small C++ program a little while ago (something to do with Windows Terminal Server API), nothing all that cool really. Hope you are well. Apolgies for the SEVEN MONTH lag in replying.
Cheers,
JT
We miss you John.
Jugoslav
Hi Jugoslav,
How are you doing? And how are all my VF friends? Hope everyone is well. I am alive! Well? Well that's a tougher question! Nah, everything's fine. Just doing different stuff. Over the last year I became responsible for the I/T departments for my division in the US. Haven't written any code in a long while. Bummer. Actually, I wrote a small C++ program a little while ago (something to do with Windows Terminal Server API), nothing all that cool really. Hope you are well. Apolgies for the SEVEN MONTH lag in replying.
Cheers,
JT
We miss you John.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've looked at the ARRAYS example and come up with this simple bit of code f90 code which I build into a dll...
! mc1.f90
!
! FUNCTIONS/SUBROUTINES exported from mc1.dll:
! mc1 - subroutine
!
subroutine mc1(a)
!dec$ attributes dllexport, stdcall, alias : "mc1" :: mc1
!dec$ attributes reference :: a
use dfcom
implicit none
! Interface.
pointer (a, SADummy) !Pointer to a SafeArray structure
integer SAdummy
! Locals
integer :: iRes, lbound, ubound
iRes = SafeArrayGetUBound(a, 1, ubound)
iRes = SafeArrayGetLBound(a, 1, lbound)
open(99, file="c:temptest.txt", status='unknown')
write(99,*)"upper bound = ",ubound
write(99,*)"lower bound = ",lbound
close(99)
end subroutine mc1
When I declare the interface to be Double[] and attempt to call it with the .NET runtime by passing it a Double[] I get two zeros in the log file for the upper and lower bounds and the array back intact.
If I declare the interface to be "ByRef a As Double[]" I get the same result in the log file but the array a is returned truncated down to only the first element.
Can anyone shed some light on this?
Thanks
Roger
! mc1.f90
!
! FUNCTIONS/SUBROUTINES exported from mc1.dll:
! mc1 - subroutine
!
subroutine mc1(a)
!dec$ attributes dllexport, stdcall, alias : "mc1" :: mc1
!dec$ attributes reference :: a
use dfcom
implicit none
! Interface.
pointer (a, SADummy) !Pointer to a SafeArray structure
integer SAdummy
! Locals
integer :: iRes, lbound, ubound
iRes = SafeArrayGetUBound(a, 1, ubound)
iRes = SafeArrayGetLBound(a, 1, lbound)
open(99, file="c:temptest.txt", status='unknown')
write(99,*)"upper bound = ",ubound
write(99,*)"lower bound = ",lbound
close(99)
end subroutine mc1
When I declare the interface to be Double[] and attempt to call it with the .NET runtime by passing it a Double[] I get two zeros in the log file for the upper and lower bounds and the array back intact.
If I declare the interface to be "ByRef a As Double[]" I get the same result in the log file but the array a is returned truncated down to only the first element.
Can anyone shed some light on this?
Thanks
Roger

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page