MELDAW Posted April 19, 2023 Report Share Posted April 19, 2023 Hello Everyone, Can anyone tell me how is the functions compare strings is working? Thank you, Link to comment Share on other sites More sharing options...
ORSO2001 Posted April 19, 2023 Report Share Posted April 19, 2023 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 More sharing options...
MELDAW Posted April 19, 2023 Author Report Share Posted April 19, 2023 Hi ORSO, Thank you for replay, Perfect i got it, thank you so much ^^ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now