Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on January 29, 2022, 01:58:08 PM
-
No matter how I rearrange the MATH statement, when vInjCounter = 0 I get an array out of bounds error. Why is this giving the array out of bounds when the IF is attempting to prevent this? I've rearranged the IF arguments every way and it still gives the error.
-
No matter how I rearrange the MATH statement, when vInjCounter = 0 I get an array out of bounds error. Why is this giving the array out of bounds when the IF is attempting to prevent this? I've rearranged the IF arguments every way and it still gives the error.
Unlike a high level language, the MATH IF() executes both sides always, it's just choosing which one to assign. The easy answer is to just clear the error immediately after the instruction, but it shouldn't be hard to use a MAX(vInjCounter-1, 0) on the index to prevent it from ever being negative in the case you aren't using.