Jump to content

Compare Strings.


Recommended Posts


you have to consider the string variable as a classic C/C++ char array that end with a null pointer.

so when you create a string variable  the PLC will instace a char array with one more position for the null pointer.

every time that set a new "value" or modify actual "value" of this char array th ePLC will automatically set the null pointer at the right position (leght+1 is the last position)  to define that the "value" is finished...for example...a string variable with 10 position but without any "start value" will have the null pointer at the first position; when you will assing the value "hello" the null pointer will be moved at the 5th position...so the system will know that the variable "value" start with "h" and stop with "o" and its length is 5...

so...the "compare" FB checks if both string has the same length and all single position has the same value...if it is the power line will flow otherwise not.

so a string variable of 10 elements that contain the value "hello" and the constant string "hello" are the same.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...