Page 1 of 1
String comparison esp32
Posted: Mon Apr 20, 2026 12:12 pm
by mnfisher
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
Re: String comparison esp32
Posted: Mon Apr 20, 2026 1:16 pm
by Steve-Matrix
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.
Re: String comparison esp32
Posted: Mon Apr 20, 2026 1:27 pm
by mnfisher
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
Re: String comparison esp32
Posted: Mon Apr 20, 2026 1:35 pm
by Steve-Matrix
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.
Re: String comparison esp32
Posted: Mon Apr 20, 2026 2:06 pm
by BenR
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.
Re: String comparison esp32
Posted: Mon Apr 20, 2026 3:33 pm
by mnfisher
Thanks Steve/Ben,
Just tested - and there is sill a 255 lurking at line 517.
Martin