
Strings to Fortran dlls and back again!
Please
Has anyone called a fortran dll (generated with the MS Fortran Powerstation
4.0 ) with the hope of passing a string of variable length, have the dll
process it, and return a set of strings where the number of strings can
vary. It is not critical that the strings be of variable length as they
can be padded, but it is necessary to return a variable number of strings
from the dll. This is a problem that has bugged me for a while. By
following the example in the Fortran Manual I have the following that does
not work. I get a bad dll calling convention. Appears simple enough but
for the life of me I can't figure it....
MY VB CODE:
Public Sub RunBatch(control As control, CharNumb As Long, LineNumb As Long)
Dim bstring As String * 40 ' Fixed-length string
'Run the thing
Call TESTR(bstring)
End Sub
My declaration is:
Public Declare Sub TESTR Lib "c:\dlls\teststring\debug\teststring.dll"
(ByVal bstring As String)
MY FORTRAN CODE:
SUBROUTINE TESTR(bstring)
C
!MS$ATTRIBUTES DLLEXPORT :: TESTR
!MS$ATTRIBUTES ALIAS :'TESTR' :: TESTR
C
CHARACTER(40) bstring
bstring = 'Hello, Visual Basic!'
END
Any suggestions much appreciated:
Please reply to
David Bates
Department of Economics
University of British Columbia
Vancouver
Canada