According to [log in to unmask] message, dated 20-JAN-2000,
with subject: Re: Question on character valued functions
> > The problem with TRIM (i.e. my_trim) is clear. It returns a character string
> > with length equal to input string s due to the declaration:
> > CHARACTER(LEN=LEN(s)) :: my_trim
> > but what else can I do?
>
> This looks strange as well:
>
> > my_len_trim = VERIFY(s, space//tab, BACK=.TRUE.)
>
> Don't you want
>
> VERIFY(s, " "//," ", BACK=.TRUE.)
> or perhaps something using ACHAR to make the source code more readable?
I have deleted my posting but perhaps I screwed up the source code. I "copied"
it by hand from the pc to alpha. The space, tab are parameters:
CHARACTER(LEN=1), PARAMETER, PRIVATE :: space = ACHAR(32)
CHARACTER(LEN=1), PARAMETER, PRIVATE :: tab = ACHAR(9)
or the whole source code again:
----------------------------------------------------------------------------
MODULE charutils
IMPLICIT NONE
INTERFACE LEN_TRIM
MODULE PROCEDURE my_len_trim
END INTERFACE LEN_TRIM
INTERFACE TRIM
MODULE PROCEDURE my_trim
END INTERFACE TRIM
CHARACTER(LEN=1), PARAMETER, PRIVATE :: space = ACHAR(32)
CHARACTER(LEN=1), PARAMETER, PRIVATE :: tab = ACHAR(9)
CONTAINS
FUNCTION my_len_trim(s)
INTEGER :: my_len_trim
CHARACTER(LEN=*), INTENT(IN) :: s
my_len_trim = VERIFY(s, space//tab, BACK=.TRUE.)
RETURN
END FUNCTION my_len_trim
FUNCTION my_trim(s)
CHARACTER(LEN=*), INTENT(IN) :: s
CHARACTER(LEN=LEN(s)) :: my_trim
my_trim = s(1:LEN_TRIM(s))
RETURN
END FUNCTION my_trim
END MODULE charutils
----------------------------------------------------------------------------
PROBLEM: Again the problem is that: TRIM('A b ') will return 'A b ' instead of
'A b'.
Thank you again for any ideas/help. Regards,
Petros
----------------------
Petros Dafniotis, PhD
DuPont de Nemours Intl. S.A. - Central Research & Development
[log in to unmask]
---
DISCLAIMER: My employer, DuPont de Nemours, has nothing to do with
the opinions and ideas expressed in this post / message.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|