For Programmers: Free Programming Magazines  


Home > Archive > Fortran > January 2006 > Re: How to compare two strings?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: How to compare two strings?
robin

2006-01-30, 9:57 pm

jane.sync@yahoo.com wrote in message <1138579119.465314.236400@g49g2000cwa.googlegroups.com>...
>I thought I could test two strings with the code below, but it doesn't
>work. I'm passing a string into the function below, but the result is
>always 'not equal'. How are strings compared in Fortran 77?


This is Fortran 90 or later.

> function evaluateinput(str1) result(string)
> implicit none
> character(12) str1


character(len=*) :: str1
is required for a dummy argument that receives an argument
whose length can be anything.

> character(12) string
> if (str1 .EQ. 'test') then


if (str1 == 'test') then

> string = 'equal'
> else
> string = 'not equal'
> endif
> return
> end



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com