String comparison esp32

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
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

String comparison esp32

Post 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
Attachments
comapre_test.fcfx
(10.35 KiB) Downloaded 6 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

Post 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.

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

Post 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

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

Post 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.

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

Post 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.

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

Post by mnfisher »

Thanks Steve/Ben,

Just tested - and there is sill a 255 lurking at line 517.

Martin

Post Reply