Re: How to compare two strings?
- From: "robin" <robin_v@xxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 02:21:20 GMT
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.
> will still work.
>The fix? Replace
>
>character(12) str1
>
>by
>
>character(*) strl
str1
.
- Follow-Ups:
- Re: How to compare two strings?
- From: Rich Townsend
- 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
- Re: How to compare two strings in 77?
- From: Rich Townsend
- How to compare two strings in 77?
- Prev by Date: Re: Subroutine question
- 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?
- Index(es):
Relevant Pages
|