Re: How to compare two strings?

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
>character(*) strl