silverfrost Site Admin
Joined: 29 Nov 2006 Posts: 191 Location: Manchester
|
Posted: Sun Sep 05, 2004 7:04 pm Post subject: Passing arrays of strings from C# to FTN95 .NET |
|
|
An array of .NET strings can be passed from C# to FTN95 .NET routine. This string array can then be copied to a fortran character string array one by one. The following code is an example of this:
Code: |
subroutine test (a, a_size, a_elem_length)
string a(0
integer a_size, a_elem_length
character(a_elem_length) b(a_size)
assembly_interface(name="test")
do i=1,a_size
b(i) = a(i-1) ! copy the .NET strings to a fortran character string array, one element at a time
end do
end
|
The above fortran subroutine could be called from C# with the following code (where test_interface is the name of the DLL/MDL containing the fortran subroutine).
Code: |
string[] s = new string[3];
s[0] = "aaaaa";
s[1] = "bbbbb";
s[2] = "ccccc";
test_interface.test(s, 3, 5);
|
|
|