Need some verification from my hardware experts before I file a bug report.
I’m writing a text-wrapping routine for a text adventure that I’m writing. I’m running into a problem with
string.indexOf(needle, fromIndex)
when running on hardware. Code below; URL for a shared project is at the end if that’s easier.
// 0 1 2 3
// 0123456789012345678901234567890
let myString: string = 'Well, hello there! How are you?'
let previousSpace: number = 0
let nextSpace: number = myString.indexOf(' ', previousSpace + 1)
let round: number = 0
while (nextSpace !== -1) {
game.showLongText('Round: ' + round +
' previousSpace: ' + previousSpace +
' nextSpace: ' + nextSpace,
DialogLayout.Bottom)
previousSpace = nextSpace
nextSpace = myString.indexOf(' ', previousSpace + 1)
round++
} // while (nextSpace)
game.showLongText('Final round: ' + round +
' previousSpace: ' + previousSpace +
' nextSpace: ' + nextSpace,
DialogLayout.Bottom)
In the browser simulator, it runs fine, ending after five rounds and finding all of the spaces in the string. On my BrainPad Arcade, though, it gets stuck on the first space. It seems to be ignoring the second parameter in the method call. Same issue on beta.
Can I get confirmation that others are experiencing the same thing? MakeCode devs: Let me know if you need me to file a bug report and, if so, against which repository (arcade, pxt-common, pxt, or elsewhere).
Thanks!