problems with increments in arrays

Posted on
  • The following code causes an infinite loop and Out of Memory warnings:

      var contents = [1,1,1,2,1,3,2,1,3,1,3,2,4,1,5,1,6,1,6,2­,6,3];
      var i = 0;
      for (i = 0; i < contents.length; i = i + 2) {

    The problem has to do with print(contents[i+1]);so I assume the issue is in the use of i+1at that spot.

    The following modification exposes the same, bad behaviour:

        j = i + 1;
  • Thanks. I'll look into this after the weekend. It could actually be a regression in the latest version of the software as I had tried to speed up array accesses.

  • I just tried both of these and they work fine for me. Either pasted into the left or right hand sides of the Web IDE.

    Maybe someone else can confirm whether they see the problem as well?

  • I'm not seeing it on all my boards ... Just tried it with another one and there are no issues. I still have the original code lying around so will try that again this evening on the original board (no time now, and code used the screen so need to do some wiring up).

  • It works both on my discovery and my espruino's.

  • This will probably have been myself goofing up. I have had issues with the screen since day one, where sometimes it works flawlessly and other times, after reconnecting, I cannot get anything drawn on there. Might just be faulty wiring or something that is the cause (no idea how to check that though), but it definitely sounds like it isn't the software.

  • It's possible it's a missing character - the problem should have gone away with changes in the last few months, but I guess it is possible that occasionally characters will still get lost.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

problems with increments in arrays

Posted by Avatar for Kim @Kim