5 Sep 2004 6:04
#21
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:
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).
string[] s = new string[3];
s[0] = 'aaaaa';
s[1] = 'bbbbb';
s[2] = 'ccccc';
test_interface.test(s, 3, 5);
-- Admin Silverfrost Limited