View previous topic :: View next topic |
Author |
Message |
Anonymous Guest
|
Posted: Mon Mar 06, 2006 2:30 am Post subject: character* in .Net |
|
|
I am trying to invoke the following subroutine from C#
I supposed that character* is automatically converted into String as real* is converted into Double, however
it doesn't work as expected. What did I wrong?
!*-------------------------------------------------------------------------
!* revbuf -- reverse the order of the contents of a buffer
!*-------------------------------------------------------------------------
subroutine REVBUF (buf)
character*20 buf
character*1 temp
integer*4 width,data_width
! character*20 dll_export :: REVBUF
! ASSEMBLY_INTERFACE(NAME="REVBUF")
width = len(buf)
data_width = index (buf,char(0))
!c----------------------------------------------------------------------
!c We pad the string with blanks on the end because osl passes the
!c string with binary 0 at the end of the data within the field.
!c Note: data_width will be 0 if the string fills the field.
!c----------------------------------------------------------------------
if (data_width .ne. 0) then
buf(data_width:width) = ' '
end if
j = width
do i = 1 , j/2
temp = buf(i:i)
buf(i:i) = buf(j:j)
buf(j:j) = temp
j=j-1
end do
do i = 1 , width
if (buf(i:i) .eq. '(') then
buf(i:i) = ')'
else if (buf(i:i) .eq. ')') then
buf(i:i) = '('
else if (buf(i:i) .eq. '[') then
buf(i:i) = ']'
else if (buf(i:i) .eq. ']') then
buf(i:i) = '['
else if (buf(i:i) .eq. '{') then
buf(i:i) = '}'
else if (buf(i:i) .eq. '}') then
buf(i:i) = '{'
else if (buf(i:i) .eq. '<') then
buf(i:i) = '>'
else if (buf(i:i) .eq. '>') then
buf(i:i) = '<'
end if
end do
return
end
Boris Gilad |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Mon Mar 06, 2006 10:07 am Post subject: character* in .Net |
|
|
Boris
Please see "Calling Fortran from other .NET languages" in the help file where it says...
"Fortran CHARACTERs are mapped to System.String objects and passed by value (this means that changes made to a dummy argument are not passed back to the actual argument at the point of call)."
In other words, you can make the call and do the changes but they will not be reflected back to the point of call.
My first thought is that the simplest approach may be to write this part of the code in C#.
|
|
Back to top |
|
|
Anonymous Guest
|
Posted: Tue Mar 07, 2006 12:22 am Post subject: character* in .Net |
|
|
Paul,
Thanks for the prompt answer. |
|
Back to top |
|
|
|