Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

call fortran method with strings array

$
0
0

Hello,

how can I call a Fortran method (DLL) with Strings array in parameter (by ref)

I try MarshalAS, StringBuilder[], [in,out] ...but bothing work

 

Here Fortran Code

 SUBROUTINE PARAM_REF (I2, I4, C6, R4, tabi, tabS, By)use, intrinsic ::ISO_C_BINDING

      IMPLICIT NONE
     
      INTEGER*2 I2
      INTEGER*4 I4
      CHARACTER*6 C6
      REAL*4 R4
      INTEGER*4	    tabi(3)
      CHARACTER*3   tabS(3)
      Byte by

      
      !DEC$ ATTRIBUTES DLLEXPORT :: PARAM_REF
      !DEC$ ATTRIBUTES ALIAS:'PARAM_REF'::PARAM_REF
    ...
      END SUBROUTINE

Here C# Code

 [DllImport("dll1.dll")]publicstaticexternvoid PARAM_REF(
           [MarshalAs(UnmanagedType.I2)] ref Int16 i2,
           [MarshalAs(UnmanagedType.I4)] ref Int32 i4,
           [MarshalAs(UnmanagedType.VBByRefStr)] refstring c6,
           [MarshalAs(UnmanagedType.R4)]reffloat r4,
           [MarshalAs(UnmanagedType.LPArray)] int[] tabi,ref String[] tabS,ref Byte by);privatevoid btnPARAM_REF_Click(object sender, EventArgs e)
        {
            String[] tabS = new String[] { "aze", "ABc", "123" };
 ...
            PARAM_REF(ref i2, ref i4, ref c6, ref r4, tabi,ref tabS, refby);
        }

 

 

 

 


DT

Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>