clickety6
2005-07-14 08:16:28 UTC
I would like to have a function where I cna pass in an array of
variable length and a charcter string of variable length and have
returned a character string of varibale length. There seems to be lots
of different ways of declaring the type of function (maybe the one
chosen below isn't the best - I'm failry new to F90!), but there seems
to be no way of getting a function to return a string of variable
length. Is this possible? Am I misisng something obvious?
Thanks!
Tim
EXAMPLE:
==========
PROGRAM test
INTEGER(KIND=1):: buffer(10)
CHARACTER(LEN = 10) :: string
string = byte2char(buffer, string)
CONTAINS
FUNCTION byte2char (buffer, string)
INTEGER(KIND=1):: buffer(:)
CHARACTER(LEN = *) :: string
CHARACTER(LEN = *) ::
string = TRANSFER(buffer, string)
END FUNCTION byte2char
END PROGRAM test
variable length and a charcter string of variable length and have
returned a character string of varibale length. There seems to be lots
of different ways of declaring the type of function (maybe the one
chosen below isn't the best - I'm failry new to F90!), but there seems
to be no way of getting a function to return a string of variable
length. Is this possible? Am I misisng something obvious?
Thanks!
Tim
EXAMPLE:
==========
PROGRAM test
INTEGER(KIND=1):: buffer(10)
CHARACTER(LEN = 10) :: string
string = byte2char(buffer, string)
CONTAINS
FUNCTION byte2char (buffer, string)
INTEGER(KIND=1):: buffer(:)
CHARACTER(LEN = *) :: string
CHARACTER(LEN = *) ::
string = TRANSFER(buffer, string)
END FUNCTION byte2char
END PROGRAM test