Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

SRP_Precompiler code for For Each

I am experiencing crashes using For Each statements in my code. I looked at the pragma output, and I think I found where the errors are occurring.

It looks like the SRP_Precompiler will set up For Each statements with a Common statement for all the common variables necessary to process the loop efficiently. It looks like it places this Common statement only on the first instance of a For Each statement. If that first instance of the For Each statement happens to not run before another instance of a For Each statement then the Common variables are not set up and the program crashes. If this is indeed causing the crash, then I would suggest putting the common statement at the top of the program, before any branching occurs.

Comments

  • I was able to stop the crashing by putting a "dummy" For Each statement at the very top of the function to make sure that the common statement occurred before any gosub branching.
  • Good catch. I didn't consider that condition. I'll make a note to update the pre compiler.
  • I do not know if this is the same issue, I have a pragma line showing up in my OI code, I use SRP's editor, latest version. I did not put this line in, one day I just happen to notice the line was next to my INCLUDEs/INSERTs. Can I remove it? TIA.
  • Technically this is not the same issue although we are taking about the same underlying technology: the SRP Precompiler.

    What I mean is that you are not reporting an issue per se. The original poster reported a crash that was due to a small bug with the SRP Precompiler. You are merely reporting the existence of the SRP Precompiler pragma line.

    That said, the SRP Editor will automatically add this line for you if it detects the use of enhanced BASIC+ syntax (like the For Each statement). Are you using enhanced BASIC+ syntax? If not, then I'm not sure why this line got automatically added for you. It won't hurt anything but you might not be able to remove it as long as the SRP Editor thinks it should be there. If you are not expecting it then send me your code so I can identify what might be triggering the auto-add feature of the SRP Editor.
  • Correct - I am not reporting an issue/error, I am curious as to why the line showed up, I could have hit a keystroke that did it, just not that familiar with it. "Are you using enhanced BASIC+ syntax" - yes.
  • "Are you using enhanced BASIC+ syntax" - yes.
    Cool. Then that resolves the mystery.
Sign In or Register to comment.