Home AMX User Forum NetLinx Studio

Any Idea What This Error Means?

1: 04-26-2006 WED 09:53:37 Interpreter SetVariable - Error 1 Tk=0x0000
2: 04-26-2006 WED 09:53:37 Interpreter Ref Error ^DCMUSIC_SELECT Index 0

Thanks!

Comments

  • DHawthorneDHawthorne Posts: 4,584
    You referenced an array with zero as the index. Like so: DCMUSIC_SELECT[0] .. or the variable in the array index resolves to zero when it runs. You have to test for values of arrays when you use them, there is no internal bounds checking, zero or overruns only generate run-time errors. If your code can't possibly set it to zero, then it's as easy as initializing it to a non-zero default. If zero is a valid value for that variable, then you have to check it's not zero before referencing it in the array.
  • matt95gsrmatt95gsr Posts: 165
    I've seen similar when using for loops that start at 0, or some other type of dynamic variable assignment that inadvertently references a 0 value.
    for (i=0;i<=5;i++)
    {
      DCMUSIC_SELECT[i] = (someothervar = i)
    }
    

    Maybe you're dealing with something like that...?
  • jjamesjjames Posts: 2,908
    Curious

    Slightly off topic - but why would anyone initialize FOR loops with a zero???? We should all know that NetLinx's arrays are not zero-based. Wasn't that covered in P1?
  • matt95gsrmatt95gsr Posts: 165
    I agree jjames... I don't know why, but I know I've seen it happen before. But yes, I think that was a topic covered pretty early on.
  • DHawthorneDHawthorne Posts: 4,584
    If you have any kind of programming experience outside of AMX, it's just habit. I haven't coded in straight C++ for years, yet I still struggle with the zero vs. one based array indexing. But most of the time, it's simply a matter of forgetting to initialize your index at all. Since the constructors in Axcent and NetLinx initialize all variables to zero, if you forget to change that, your index is automatically broken until you do.
Sign In or Register to comment.