Page 1 of 1

String compare function

Posted: Tue Apr 25, 2023 2:23 am
by henker
Hello

Trying to figure out why the "string Compare" function doesn't work for me.
I have to strings that are identical however, the return value of the compare function still returns 255.
Same applies if the 2 strings are not the same... still 255

Flag_identifier = Compare$ (.Identifier,Word_received,1)

Anyone that can steer me in the right direction?

Thanks
Henk

Re: String compare function

Posted: Tue Apr 25, 2023 8:43 am
by chipfryer27
Hi

In the attachment I have four strings

S1 = "abc123"
S2 = "123456"
S3 = "abc123"
S4 = "ABC123"

In calculation boxes I compare them in various order and case sensitivity. If you step through the chart the variable "x" will display the result. Works fine for me.

However I notice you are using a local variable for String1 (.Identifier), could that be the problem? A local variable is only available inside the macro that uses it. A return of 255 means String2 is greater than String1.

Regards

EDIT
Did a test using locals. Didn't like that at all. I set .x1 to 128 as that would never be returned, and did a compare .x1 never changed in value.

Re: String compare function

Posted: Tue Apr 25, 2023 11:56 am
by henker
Thanks CF
Weird enough, in simulation mode you can use the local and it actually works. Tonight I will change the local to a global and see if that makes the difference

Henk