Software Archive
Read-only legacy content
17061 Discussions

String Arrays from VB

Intel_C_Intel
Employee
340 Views
I'm trying to pass an array of strings from VB, to a DVF dll. Currently, I have followed the mixed language example that comes with the software (DF98samplesmixlangvbarraysarrays.f90) and it works fine. However, this example passes only one argument, the string array. When I try to add additional arguments to the argument list, I get an "out of stack space" or "bad dll calling convention" error.

What is the cause of this and how is it possible to add additional arguments to the list without tripping these errors? My guess is that it is in either the VB declaration, or in the DVF, !DEC$ parameters in the fortran code. I've tried numerous permutations and variations but can't seem to get it to work.

To replicate this error, take the arrays.f90 code cited above, and add a Long Integer N, to the argument list just after 'VBArray' in the dll, and just after 'mystring' in the VB declaration and the VB code.
0 Kudos
4 Replies
canaimasoft
Beginner
340 Views
Here is an example pulled out from our f90VB User manual (I made some minor modifications):



subroutine BBStrSort(USAHndl, SSAHndl, CaseSensitive, iError)

!This subroutine uses the bubble sort algorithm
!to sort a vector of strings (USAHndl). The
!sorted vector is returned in SSAHndl

!DEC$ATTRIBUTES STDCALL:: BBStrSort
!DEC$ATTRIBUTES DLLEXPORT:: BBStrSort
!DEC$ATTRIBUTES ALIAS: 'BBStrSort':: BBStrSort
!DEC$ATTRIBUTES REFERENCE:: USAHndl, SSAHndl, CaseSensitive, iError
implicit none

!Subroutine arguments
integer(4),intent(in)::USAHndl
integer(4),intent(inout)::SSAHndl
integer(2),intent(in)::CaseSensitive
integer(2),intent(inout)::iError

? (subroutine body goes here)

end subroutine BBStrSort



In the subroutine body you would need to call the appropriate Windows APIs to handle the Safe Arrays and their BStrings.

On the visual basic side, you would declare this sub as:



Declare Sub BBStrSort Lib "Example52.dll" (UStrArray() As String, SStrArray() As String, CaseSensitive As Boolean, iError As Integer)


Best regards,

Marco A. Garcia
Canaima Software, Inc.
http://www.canaimasoft.com
Developers of f90SQL the Database Connectivity Solution for Fortran, and f90VB the Library for Fortran-OLE Automation and Fortran-VB Programming
0 Kudos
canaimasoft
Beginner
340 Views
Steve,

What's up with the newgroup software? When you post a message, the preview shows one format, when the message is posted, it comes out with all newlines removed. Is there a way around this problem?. The forum's help doesn't seem to help here....

Marco Garcia
Canaima Software
0 Kudos
Steven_L_Intel1
Employee
340 Views
Marco,

That's the way it works, unfortunately. Bracket your code with ... and it will be (mostly!) left alone. If you have any angle brackets in the text, use < and > instead.

We're investigating an alternate message board solution that should be a lot better in these areas. Sorry for the inconvenience.

I will edit your post appropriately.

Steve
0 Kudos
durisinm
Novice
340 Views
I'm certainly not an expert at this, but the postings accept certain HTML tags. The tags are necessary to properly format certain items, like code postings. The pre and /pre tags and others should work for this.

Mike Durisin
0 Kudos
Reply