Re: How to compare two strings?
- From: Rich Townsend <rhdt@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 30 Jan 2006 21:30:57 -0500
robin wrote:
Rich Townsend wrote in message ...
jane.sync@xxxxxxxxx wrote:
I think I got it. Does the following code look like something a Fortran programmer would use to test two strings?
function evaluateinput(str1) result(string) implicit none character(12) str1 character(12) string if (LLT(str1,'test')) then string = 'less than' else if (LGT(str1,'test')) then string = 'greater than' else string = 'equal' end if return end
I think you've found a work-around, not a fix. The problem is the declaration of str1. If you pass a string of length shoother than 12, (say, 5), then the characters of str1 from position 6 onwards will contain garbage. It is this garbage that prevents str1 from being equal to 'test'; but the collating operators (LLT and LGT)
These are functions, not operators.
Wow, thanks for correcting that gaping hole in my assesment. My mistake totally invalidates the advice I offered the OP.
.
- References:
- How to compare two strings in 77?
- From: jane . sync
- Re: How to compare two strings in 77?
- From: jane . sync
- Re: How to compare two strings in 77?
- From: Rich Townsend
- Re: How to compare two strings?
- From: robin
- How to compare two strings in 77?
- Prev by Date: Re: How to detect NULL input?
- Next by Date: Question on allocatable arrays in Fortran 90
- Previous by thread: Re: How to compare two strings?
- Next by thread: Re: How to compare two strings in 77?
- Index(es):
Relevant Pages
|
|