Topic: DMD0164

STRCMP - String Compare


The String Compare (STRCMP) instruction will compare the contents of one String to the contents of a second String or to a string literal. The STRCMP instruction determines if two Strings are Equal, Less Than or Greater Than by comparing the byte values of the characters in the respective Strings. The byte value of a String or a string literal is the decimal values assigned to each character. The byte values for each character can be seen in the ASCII Character Table.

 

The instruction compares the byte values for the characters in order until one of the following happens:
 

  • the byte values don't match, this means the string with the smaller byte value is 'less than' the string with the larger byte value
     

  • the end of one string is reached but the other has remaining characters, this means the shorter string is 'less than' the longer string and the longer string is 'greater than' the shorter string
     

  • the end of both strings is reached at the same time, meaning the strings are equal

 

Parameters:

Note: Use the F9 key (Element Browser) or Down-Arrow key (Auto-Complete) at any time to see a complete list of the memory locations that are valid in the current field of the instruction.

 

First String - this can be any String element.

 


Case Sensitive
 

  • Yes, upper/lower case are different - select this option if the comparison needs to distinguish between upper case and lower case versions of the same characters, that is, "A" is NOT the same as "a"
     

  • No, upper/lower case are equal - select this option if the comparison does not need to distinguish between upper case and lower case versions of the same characters, that is, "A" is the same as "a"

 


Set If Equal - if this option is selected the First String and the Second String or Text must be equal to set the designated BIT location ON. This can be any writable bit location.

 

Set If Less Than - if this option is selected the First String must be less than the Second String or Text to set the designated BIT location ON. This can be any writable bit location.

 

Set If Greater Than - if this option is selected the First String must be greater than the Second String or Text to set the designated BIT location ON. This can be any writable bit location.

 


Second String or Text - this can be any String element or a string literal.

 


Status Display:

The Status display of the String Compare instruction will only display as many of the characters of the First String and Second String or Text as will fit within the borders of the instruction, typically this is about 50 characters.

 

The gray triangle at the right end of an input leg indicates the input is edge triggered.

 


See Also:

 


Related Topics:

String Functions Overview

 

String Scripting Language Reference

 


Rung Example: