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
Fonction "COMPARE"
Moderator: Benj
- 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"
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
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
-
- Posts: 36
- Joined: Mon Mar 12, 2012 9:14 pm
- Has thanked: 5 times
- Been thanked: 7 times
- Contact:
Re: Fonction "COMPARE"
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
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
- 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"
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. Cheers,
Jonny
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. Cheers,
Jonny
-
- Posts: 36
- Joined: Mon Mar 12, 2012 9:14 pm
- Has thanked: 5 times
- Been thanked: 7 times
- Contact:
Re: Fonction "COMPARE"
Ok
Pending V5.2, I'll change my project accordingly.
thank you for your check.
Steve
Pending V5.2, I'll change my project accordingly.
thank you for your check.
Steve