PDA

View Full Version : array of .NET strings in LF Fortran v7.0?


kschartz
11-12-2003, 06:20 AM
I am trying to use the Environment.GetCommandLineArgs() method in my code. This method returns an array of strings (string[] in C# syntax). I am familiar with the syntax for declaring a scalar string in Fortran using something like:

USE System
type(String), pointer :: ustr ! unicode string

However, I cannot determine the correct syntax for declaring an array of strings in LF Fortran v7.0

Any help would be appreciated. Thanks.

tzeis
11-12-2003, 07:56 PM
The correct syntax is known as "assumed shape", and is specified with a (:).

For example, a program that retrieves the command line args might have code that looks like this:


use System
type (String), pointer :: cl(:)
cl => Environment%GetCommandLineArgs()
do j = 1, size(cl)
write(*,*) string(cl(j-1))
end do
end


You could also use the DIMENSION attribute:


type (String), pointer, dimension(:) :: cl

kschartz
11-12-2003, 08:25 PM
Thanks! I had forgotten about assumed-shape arrays. Your suggestion and example code are much appreciated.