We can compare two strings using this function.
This is the example from the official documentation and the explanation by Eng. Mahmoud Fayed.
see strcmp ('hello', 'hello') + nl #output: 0, the two strings are typical. see strcmp ('a', 'b') + nl #output: -1, the 'a' letter in ASCII is 97, 'b' in ASCII is 98, then 'a' < 'b' and the output is -1 see strcmp ('b', 'a') + nl #output: 1, because 'b' > 'a' in ASCII.
But, in case you just want to see if the strings are the same or not we can do this:
give str if strcmp (str, 'hello') = 0 see `The string you entered does match.` else see `The string you entered doesn't match.` ok
NOTE: In the if statement here, we use only one = not == like in the other languages.
Then test it:
input: hello output: The string you entered does match. input: Hello output: The string you entered doesn't match.
This is basically how it is done.
See you in the next post.