Jump to content

Compare Strings.


MELDAW

Recommended Posts

Hi MELDAW,

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.