PDA

View Full Version : Character Arrays


bmptti
03-05-2009, 06:01 PM
Hello,

I have a VB.NET application in which I call a Fortran .NET DLL. How do you retrieve Character array values from Fortran to VB?

Thanks,

Brad



Here is what I have:

In VB.NET:

Dim clsFortran as New FortranModule.FortranL.FortranClass

Call clsFortran.FortranSubroutine

msgbox FortranGlobalModule.FortranGlobalModule.VB_WNAME(0 )

In Fortran:


MODULE GlobalModule
use System
use System%Windows%Forms

TYPE (System%String), POINTER, DIMENSION (:) :: VB_WNAME
END MODULE GlobalModule


In fortran subroutine:

USE GlobalModule

ALLOCATE(VB_WNAME(3))

VB_WNAME(:)=>USTRING(WNAME(:)) ! Where WNAME is a CHARACTER variable.


When I try to build this DLL I get the following errors:

error FRT1386: Pointer object in pointer assignment statement must be a variable name or a structure component which has the POINTER attribute. (on VB_WNAME(:)=>USTRING(WNAME(:)))

error FRT2565: SOURCE= specify missing. (on the ALLOCATE statement)



What am I doing wrong?

tzeis
03-08-2009, 06:10 AM
The USTRING function only accepts scalar character variables, not arrays, so you will have to use a loop to assign the string array.

Use something like

ALLOCATE(VB_WNAME(3), source = ustring(""))

For a source argument.

bmptti
03-11-2009, 03:28 PM
Thanks. That did the trick.