String comparison: Difference between revisions

Content added Content deleted
Line 602: Line 602:
=={{header|Harbour}}==
=={{header|Harbour}}==
We will compare two strings, ''s1'' and ''s2''. The following comparisons are case sensitive.
We will compare two strings, ''s1'' and ''s2''. The following comparisons are case sensitive.
<lang harbour> IF s1 == s2
<lang visualfoxpro>IF s1 == s2
? "The strings are equal"
? "The strings are equal"
ENDIF
ENDIF
IF .NOT. (s1 == s2)
IF !( s1 == s2 )
? "The strings are not equal"
? "The strings are not equal"
ENDIF
ENDIF
IF s1 > s2
IF s1 > s2
? "s2 is lexically ordered before than s1"
? "s2 is lexically ordered before than s1"
ENDIF
ENDIF
IF s1 < s2
IF s1 < s2
? "s2 is lexically ordered after than s1"
? "s2 is lexically ordered after than s1"
ENDIF</lang>
ENDIF</lang>
To achieve case insensitive comparisons, we should use Upper() or Lower() functions:
To achieve case insensitive comparisons, we should use Upper() or Lower() functions:
<lang harbour> IF Upper(s1) == Upper(s2)
<lang visualfoxpro>IF Upper( s1 ) == Upper( s2 )
? "The strings are equal"
? "The strings are equal"
ENDIF
ENDIF</lang>
</lang>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==