Tell me what you want, What you really, really want.

Moderator: Mmiscool

User avatar
By disco4now
#32930 When running the blinker program I noticed it was a lot more on than off. Looks like the program is slow when doing branching. Looking at the source it looks like a full scan of the entire program is done to resolve the line that has the branch label. I put a couple of extra goto's in the loop like this
.....
goto [here1]
[here1]
goto [here2]
[here2]
IF X <= noofblinks goto {...}

and you can really notice the delay while searching for the label.
As a quick improvement a BREAK when the correct line is found would help speed it up.
Not sure how other basics do it but the population of an array with all the labels and there line number at start up, and then resolving the line number by looking up the array would be a lot faster.


Code: Select all //branching commands

  if (Param0 == "goto")
  {
    for (int i = 0; i <= TotalNumberOfLines; i++) {
      String gotoTest = BasicProgram(i);
      gotoTest.trim();

      if (gotoTest == Param1 | String(gotoTest + ":") == Param1)
      {
        RunningProgramCurrentLine = i - 1;
       BREAK;
      }
    }
    return;
  }


Regards
Gerry
User avatar
By Mmiscool
#32972 Thanks. Will be doing a rewrite and unification of all of the branch seeking code.
As per your recommendation though I did ad the break to both goto and gosub.

Will investigate better solution in the near future.
User avatar
By Mmiscool
#32974 Uploaded new build implementing the break in branch finding code.

Experiencing power issues at the moment. Don't know how long battery back ups will last if I fall silent tonight,