Re: How to compare two strings in 77?
- From: Rich Townsend <rhdt@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 29 Jan 2006 20:22:38 -0500
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) will still work.
The fix? Replace
character(12) str1
by
character(*) strl
cheers,
Rich .
- Follow-Ups:
- Re: How to compare two strings?
- From: robin
- Re: How to compare two strings in 77?
- From: jane . sync
- Re: How to compare two strings?
- References:
- How to compare two strings in 77?
- From: jane . sync
- Re: How to compare two strings in 77?
- From: jane . sync
- How to compare two strings in 77?
- Prev by Date: How to detect NULL input?
- Next by Date: Re: How to detect NULL input?
- Previous by thread: Re: How to compare two strings in 77?
- Next by thread: Re: How to compare two strings in 77?
- Index(es):
Relevant Pages
|
|