This had me scratching my head...
The Compare$ function on esp32 seems to return the wrong value.
So > returns 1, = returns 0 - but < doesn't return -1. It seems to return 255 (returns a signed byte? - but it doesn't get sign extended if assigned to an int, and FC a byte is unsigned (0..255))
The attached demonstrates - looking in CAL_STRING - Compare returns a MX_UINT8 (unsigned!) Changing this to an MX_SINT8 (or other signed type) should resolve this...
Martin
String comparison esp32
-
mnfisher
- Valued Contributor
- Posts: 1929
- http://meble-kuchenne.info.pl
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 156 times
- Been thanked: 907 times
-
Steve-Matrix
- Matrix Staff
- Posts: 1844
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 268 times
- Been thanked: 432 times
Re: String comparison esp32
Yes, there is an issue we are aware of. I raised it recently here:
https://www.flowcode.co.uk/forums/viewt ... 402#p23402
I've asked Ben if it's worth making the change you have suggested. It should be ok, but there may be projects that are specifically looking for a return of 255 which would become broken if we made is change.
https://www.flowcode.co.uk/forums/viewt ... 402#p23402
I've asked Ben if it's worth making the change you have suggested. It should be ok, but there may be projects that are specifically looking for a return of 255 which would become broken if we made is change.
-
mnfisher
- Valued Contributor
- Posts: 1929
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 156 times
- Been thanked: 907 times
Re: String comparison esp32
Thanks - I missed that post....
However - the tooltips (for example calculation-Function$) - show '-1' for less than - and simulation also returns -1 making the transfer to hardware more difficult?
Martin
However - the tooltips (for example calculation-Function$) - show '-1' for less than - and simulation also returns -1 making the transfer to hardware more difficult?
Martin
-
Steve-Matrix
- Matrix Staff
- Posts: 1844
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 268 times
- Been thanked: 432 times
Re: String comparison esp32
I agree. The simulation has always used "-1" and on the face of it, it appears to be a bug in the CAL code. But we have to be careful when changing that because it can cause problems with existing projects which is why I didn't want to make the change without a wider internal discussion.
-
BenR
- Matrix Staff
- Posts: 2171
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 592 times
- Been thanked: 780 times
Re: String comparison esp32
Thanks for letting us know and flagging the issue again.
I've rolled out the fix now so that v10 and v11 should now correctly return -1 instead of 255.
I've rolled out the fix now so that v10 and v11 should now correctly return -1 instead of 255.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel