Xojo2023r3 WebApp: .MiddleBytes - use caution

Just a suggestion to be cautious when fixing deprecated code (I work on Xojo2018 code bringing it into Xojo2023r3)

value = value.StringValue.MiddleBytes(0, maxLength)  // 2023.10.26 <gp> replaced deprecated midb(), note: it must start with 0 not 1, otherwise first char is missing
// value = midb(value, 1, maxLength)

Maybe this is obvious for everybody but it wasn’t for me, pretty substantial change to watch for. Have a happy Friday!

1 Like

apologies for the late reply but thank you for the confirmation. I just fired Xojo back up and downloaded the update only to find old projects that worked fine were crashing in flames. This project has about 150 midb’s that got auto-updated to MiddleBytes and need adjusting. Too bad they didn’t just add a “-1” to the position parameter when they updated the line! I see the position that Instr returns is still 1-based though, which seems to make this a little inconsistent. (returns 0 for “not found”, could return -1 instead, and be 0-based to match the other functions, breaking more code I suppose)

InStr is deprecated, the replacement is .IndexOf that is 0-based and return -1.

1 Like