Fonction "COMPARE"

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
waligator
Posts: 36
Joined: Mon Mar 12, 2012 9:14 pm
Has thanked: 5 times
Been thanked: 7 times
Contact:

Fonction "COMPARE"

Post by waligator »

Hi all,

I think it is a bug in the "COMPARE" string!

If the variable "Test" is rec, with writing below, the answer must be 0. As the third parameter is "1".
Return = Compare$ (Test,"REC",1)

With V5, the response is reversed.

Can you check

thank you
Steve

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Fonction "COMPARE"

Post by JonnyW »

Good evening. If the variable Test="rec" then this should return '1' - the flag is for 'case insensitive' according to the help file so "REC" and "rec" are seen as the same.

However I have only tested this in simulation but have looked at the C code for the compare and this is as expected. Can you confirm simulation is where the issue is or is it on the chip?

Jonny

waligator
Posts: 36
Joined: Mon Mar 12, 2012 9:14 pm
Has thanked: 5 times
Been thanked: 7 times
Contact:

Re: Fonction "COMPARE"

Post by waligator »

Hello Jonny,

In the help file:

Str1 = "ABC"
Str2 = "abc"

RetVal = Compare$(Str1, Str2, 1)

RetVal is now 0 as when case insensitive the two strings are identical.


In my example:

Test = "rec"

Return = Compare$ (Test,"REC",1)


the variable "Return" should contain "0" as in the example above.
but the variable "Return" is "1"

Simulation and real is the same

Steve

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Fonction "COMPARE"

Post by JonnyW »

Morning. Yes, you are right - I was thinking return '1' for match, '0' for mismatch but the function should return 0 for match.

In simulation this is because the check for the case insensitivity is missing (so checks are always case sensitive) - this will be fixed for v5.2, and apologies for this. If you wish for simulation to be OK, the only real workaround is to use the ToUpper$() and ToLower$() functions to force the case then do a case-sensitive check.

On HW, we created a simple file (attached) and this outputs as expected. It outputs '1' in simulation, but '0' on hardware, so it seems the bug is simulation only.
example_01.fcf
Simple compare
(6 KiB) Downloaded 248 times
Cheers,

Jonny

waligator
Posts: 36
Joined: Mon Mar 12, 2012 9:14 pm
Has thanked: 5 times
Been thanked: 7 times
Contact:

Re: Fonction "COMPARE"

Post by waligator »

Ok
Pending V5.2, I'll change my project accordingly.

thank you for your check.
Steve

Post Reply