- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
!DEC$ ATTRIBUTES DLLEXPORT :: passarecord
!DEC$ ATTRIBUTES ALIAS:'passarecord' :: passarecord
real(8) DP
character*10 stringa
End Type
rec.i4(2)=200
rec.i4(3)=300
rec.i4(4)=400
rec.dp=1.67
rec.stringa='abcdefghil'
RETURN
END
Declare Function passarecord Lib "pcroutdll.dll" (ByRef rec As recor) As Integer
Public Type recor
i4(1 To 4) As Long
dp As Double
stringa As String * 10
End Type
Dim rr As recor
i = passarecord(rr)
MsgBox rr.i4(1)
MsgBox rr.i4(2)
MsgBox rr.i4(3)
MsgBox rr.i4(4)
MsgBox rr.dp
MsgBox rr.stringa
End Sub
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sequence
after:
Type recor
in the Fortran code. You have misaligned fields and the compiler is padding them. SEQUENCE will stop it from doing so, and is a good idea when you are sharing a derived type with other languages.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve,
with SEQUENCE it works.
As you can see i'm a novice in mixed languages programming.....
Now i try to pass a record of n bytes, and in that record i store integer*2,integer*4,dp and strings in a way likei useCOMMON .
in VB sometimes i havecorrect results and sometimes not!
Do it depend from VB (and the record definition in it) or what?
thanks
Cecio
here the code:
VB-------
Declare Function passarecord Lib "pcroutdll.dll" (ByRef REC As recor) As Integer
Public Type recor
stringa As String * 10
i4 As Long
dp As Double
End Type
Fortran--------
INTEGER*2 FUNCTION passarecord(rec)
!DEC$ ATTRIBUTES DLLEXPORT :: passarecord
!DEC$ ATTRIBUTES ALIAS:'passarecord' :: passarecord
implicit none
Type recor
sequence
integer*1 buf(22)
End Type
integer*4 i4
real(8) Dp
character*10 str
type (recor) rec
INTEGER*1 STRINGA(10)
equivalence(str,stringa)
integer*2 i
INTENT(out) rec
str='1234567890'
i4=101
dp=1.67d0
call trs(4,i4,rec.buf(11))
call trs(8,dp,rec.buf(15))
call trs(10,stRINGA,rec.buf(1))
RETURN
END
subroutine trs(N,in,out)
integer*1 in(1),out(1)
do 1 j=1,n
1out(j)=in(j)
return
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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